Flutter 如何以编程方式退出应用程序 [英] Flutter how to programmatically exit the app

查看:38
本文介绍了Flutter 如何以编程方式退出应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何以编程方式关闭 Flutter 应用程序.我试过弹出唯一的屏幕,但结果是黑屏.

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

推荐答案

iOS版

SystemNavigator.pop():不工作

exit(0):有效,但 Apple 可能暂停您的应用程序,因为以编程方式退出应用程序违反了 Apple 人机界面指南.

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

SystemNavigator.pop():有效并且是退出应用程序的推荐方式.

exit(0):也可以使用,但不推荐,因为它会立即终止 Dart VM 进程,用户可能认为该应用程序刚刚坠毁.

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.

这篇关于Flutter 如何以编程方式退出应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆