I am actually aware of this implementation: Flutter programmatically closing the app, but when the app closes is still in background. How can I absolutely kill the app and not let it be in background?
Thank you!
I am actually aware of this implementation: Flutter programmatically closing the app, but when the app closes is still in background. How can I absolutely kill the app and not let it be in background?
Thank you!
If you don't want to use invokeMethod
, you can directly close the app using
SystemNavigator.pop(); // Only works on Android.
While exit(0)
works on both iOS and Android, it shouldn't be used on either. Read this answer for more information.
You can use exit(0)
. But app exits abruptly. You can use the below code which is much smoother.
SystemChannels.platform.invokeMethod<void>('SystemNavigator.pop')
Documentation is available here.
SystemNavigator.pop() will work for Android but it won't work in Ios side.
and
exit(0) will work for both systems but is not recommended because Ios may reject your app due to their guidelines and in Android, it stops the Dart VM process