i want try implementation AppLifecycleState using flutter.
I have Model like this :
- (string) id
- (string) name
- (bool) fingerprintStatus = false
- (bool) tokenExpiry = false
I want detect If the user exit From the App , If the user exit more than X Second i want change status tokenExpiry == true . So for handle my case i detect user Activity Using AppLifecycleState and Timer
But the problem is i don't know logic to do that. In my mind If user exit/close app , running timer for X second then update tokenExpiry . If user comeback again but the Timer not finished, Cancel and Reset Timer then do nothing.
How can i do this ?
My Expected
AppLifecycleState _appLifecycleState;
@override
void didChangeAppLifecycleState(AppLifecycleState state) {
print(state.toString());
if(_appLifecycleState == AppLifecycleState.inactive || _appLifecycleState ==
AppLifecycleState.paused){
=> Running The Timer For 10 Second
}
else{
=> Cancel The Timer and Do Nothing
}
super.didChangeAppLifecycleState(state);
}