Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to close/kill app on Flutter

Tags:

kill

flutter

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!

like image 678
Lu Chinke Avatar asked Jul 19 '18 14:07

Lu Chinke


2 Answers

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.

like image 74
CopsOnRoad Avatar answered Oct 20 '22 21:10

CopsOnRoad


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.

like image 33
MrDumb Avatar answered Oct 20 '22 21:10

MrDumb