Flutter App Lifecycle
#this method will call when app open
@override
void initState() {
super.initState();
WidgetsBinding.instance.addObserver(this);
}
#when app destroyed
@override
void dispose() {
WidgetsBinding.instance.removeObserver(this);
super.dispose();
}
#remaining states of the app, to achieve below you need to extend the class with WidgetsBindingObserver
@override
void didChangeAppLifecycleState(AppLifecycleState state) {
if(state == AppLifecycleState.resumed){
// user returned to our app
}else if(state == AppLifecycleState.inactive){
// app is inactive
}else if(state == AppLifecycleState.paused){
// user is about quit our app temporally
}
}
