Flutter how to programmatically exit the app

Question

Asked by Theo B on July 14, 2017 (source).

How can I programmatically close a Flutter application. I've tried popping the only screen but that results in a black screen.

Answer

Question answered by CopsOnRoad (source).

For iOS

SystemNavigator.pop(): Does NOT WORK

exit(0): Works but Apple may SUSPEND YOUR APP because it's against Apple Human Interface guidelines to exit the app programmatically.


For Android

SystemNavigator.pop(): Works and is the RECOMMENDED way of exiting the app.

exit(0): Also works but it's NOT RECOMMENDED as it terminates the Dart VM process immediately and user may think that the app just got crashed.

DART FLUTTER
SHARE: