didChangeAppLifecycleState is not working. I have checked all other question related to this, but not helpful.
@override
void initState() {
WidgetsBinding.instance.addObserver(this);
super.initState();
}
@override
void dispose() {
WidgetsBinding.instance.removeObserver(this);
super.dispose();
}
@override
void didChangeAppLifecycleState(AppLifecycleState state) {
// TODO: implement didChangeAppLifecycleState
UpPrint(name: "CheckUserStatus",value: "Before");
print(state);
UpPrint(name: "CheckUserStatus",value: "After");
if (state == AppLifecycleState.resumed){
//TODO: set status to online here in firestore
UpPrint(name: "CheckUserStatus",value: "Online");
UpFirebaseDB.updateUserStatus(status: true);
}else{
//TODO: set status to offline here in firestore
UpFirebaseDB.updateUserStatus(status: false);
UpPrint(name: "CheckUserStatus",value: "Offline");
}
}
Note: I have used the initialRoute: ‘/’, onGenerateRoute: UpRoutes.onGenerateRoute, for page navigation and i’m using the Getx for state management.
Thank in Advanced.