如何在Flutter中将变量值传递给AppLifecycleState.resum?

时间:2020-03-29 09:46:58

标签: flutter dart application-lifecycle

在我的应用程序中,当调用AppLifecycleState.resumed时,我想将cancelMessage变量传递给AppLifecycleState.resumed内部存在的小部件。但是在打印那条cancelMessage时,它显示为空值。

但是当我打印orderCancelled(布尔型)时,它会打印出它的值,这很正常。

    @override
  void didChangeAppLifecycleState(AppLifecycleState state) {
    if (state == AppLifecycleState.resumed) {
      print('cancelmessage from resume tracking: $cancelMessage');
     if(orderCancelled) {
       Navigator.popUntil(context, (Route<dynamic> route) => route is PageRoute);

           showDialog(
           barrierDismissible: false,
           context: context,
           builder: (context) => CustomDialog(msg: cancelMessage,)
      );
     }
    }
    super.didChangeAppLifecycleState(state);
  }

0 个答案:

没有答案