Flutter Ios 如何在没有 exit(0) 的情况下退出应用程序?

Flutter Ios how to exit app without exit(0)?

您好,我正在尝试使用按钮退出。我知道不推荐使用 exit(0) 。我试过 SystemChannels.platform.invokeMethod('SystemNavigator.pop');但它也没有任何建议? 提前致谢

对于iOS

SystemNavigator.pop():不工作

exit(0):有效,但 Apple 可能 暂停您的应用程序

请看:

https://developer.apple.com/library/archive/qa/qa1561/_index.html

如果您使用 exit(0),则该应用程序似乎崩溃了。这就是 Apple 不建议明确实施 exit(0) 的原因。

如果您想通过点击按钮退出,请向用户添加一个警告,说明您为什么必须 restrart/exit 该应用程序。因此,系统会提醒用户为什么该应用程序会对他们造成不当行为。