Flutter 应用中有Activity
种生命周期方法吗?
喜欢:
onCreate()
onResume()
onDestroy()
或者:
viewDidload()
viewWillAppear()
如何处理应用生命周期?
Flutter 应用中有Activity
种生命周期方法吗?
喜欢:
onCreate()
onResume()
onDestroy()
或者:
viewDidload()
viewWillAppear()
如何处理应用生命周期?
当系统将应用程序放在后台或将应用程序返回到名为didChangeAppLifecycleState
的前台时,会调用一个方法.
class _AppLifecycleReactorState extends State<AppLifecycleReactor> with WidgetsBindingObserver {
@override
void initState() {
super.initState();
WidgetsBinding.instance.addObserver(this);
}
@override
void dispose() {
WidgetsBinding.instance.removeObserver(this);
super.dispose();
}
AppLifecycleState _notification;
@override
void didChangeAppLifecycleState(AppLifecycleState state) {
setState(() { _notification = state; });
}
@override
Widget build(BuildContext context) {
return new Text('Last notification: $_notification');
}
}
还有100种方法可以了解应用程序可能处于的状态,例如:
这些常量的用法是常量的值,例如:
const AppLifecycleState(state)