'will AppLifecycleState active in whole applife or the page I use it
@override
void initState() {
super.initState();
WidgetsBinding.instance!.addObserver(this);
}
@override
void didChangeAppLifecycleState(AppLifecycleState state) {
if (state == AppLifecycleState.resumed) {
debugPrint("AppLifecycleState.resumed");
} else if (state == AppLifecycleState.paused) {
debugPrint("AppLifecycleState.paused");
} else if (state == AppLifecycleState.detached) {
debugPrint("AppLifecycleState.detached");
} else if (state == AppLifecycleState.inactive) {
debugPrint("AppLifecycleState.inactive");
}
}
@override
void dispose() {
WidgetsBinding.instance!.removeObserver(this);
super.dispose();
}
@override
Widget build(BuildContext context) => Scaffold();
}
this is a demoPage above,I wonder if the didChangeAppLifecycleState() method will print on any time I change app state,or just print when I change app state from DemoPage
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
