混淆 WidgetsBindingObserver
@override
void initState() {
// TODO: implement initState
WidgetsBinding.instance.addObserver(this);
super.initState();
}
@override
void dispose() {
// TODO: implement dispose
WidgetsBinding.instance.removeObserver(this);
super.dispose();
}
@override
void didChangeAppLifecycleState(AppLifecycleState state) {
// TODO: implement didChangeAppLifecycleState
print('状态$state');
super.didChangeAppLifecycleState(state);
}
评论