在我的应用程序中,当调用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);
}