I am new in Flutter. I am working on one of my demo Flutter app. I have created 3 screens (Login, Signup and Home) in my app. I am just navigating to the Home screen from the login screen. Now I want to check - Is my app is alive or closed? - by clearing the app from the recent apps in Android and IOS. I have checked AppLifecycleState.detached and also checked override method dispose() but these are not calling while user killed the app. Please help me how I come to know that my app got killed. Which method I need to use.
I have used AppLifecycleState.paused for other process. So I want any other way to handle it.
In native Android we can check this with the help of onDestroy() method and in iOS native app we can check it with the help of applicationWillTerminate() .
Which method I need to use for Flutter?
Please help me to fix it.
Thanks in Advance.
I found one solution to detect if the app destroyed or exit. In flutter we have dispose() method. In my case the dispose() method was not called when app destroyed. So I just updated my dispose() method. See the below code.
@mustCallSuper
@protected
void dispose() {
// TODO: implement dispose
print('dispose called.............');
super.dispose();
}