如何在应用程序处于抖动背景时如何在屏幕上显示警报或如何将Flutter应用的状态从暂停状态更改为恢复状态
class _MyScreenState extends State<MyScreen> with WidgetsBindingObserver{}
在initState内添加以下内容:
WidgetsBinding.instance.addObserver(this);
didChangeAppLifecycleState将为:
@override
void didChangeAppLifecycleState(AppLifecycleState state) {
super.didChangeAppLifecycleState(state);
if (state == AppLifecycleState.paused) {
// went to Background
}
if (state == AppLifecycleState.resumed) {
// came back to Foreground
}
}
这里是全文link的链接
希望对您有帮助。