暂停Flutter应用时如何显示警报?

问题描述 投票:0回答:1

如何在应用程序处于抖动背景时如何在屏幕上显示警报或如何将Flutter应用的状态从暂停状态更改为恢复状态

flutter dialog state resume pause
1个回答
0
投票
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的链接

希望对您有帮助。
© www.soinside.com 2019 - 2024. All rights reserved.