Flutter how to programmatically exit the app

后端 未结 7 1326
死守一世寂寞
死守一世寂寞 2020-11-27 03:28

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

7条回答
  •  生来不讨喜
    2020-11-27 03:49

    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.

提交回复
热议问题