Flutter - 退出App

世事洞明皆学问,人情练达即文章。这篇文章主要讲述Flutter - 退出App相关的知识,希望能为你提供帮助。
Flutter退出App的方法一般有两种
①SystemNavigator.pop  推荐
 

onTap: () async { await pop(); },

static Future< void> pop() async { await SystemChannels.platform.invokeMethod(‘SystemNavigator.pop‘); }

 
【Flutter - 退出App】别忘了引用
import ‘package:flutter/services.dart‘;

 
原文参考:  https://docs.flutter.io/flutter/services/SystemNavigator/pop.html
②exit(0)
 
onPressed: ()=> exit(0),

 
原文参考:  https://docs.flutter.io/flutter/dart-io/exit.html
 

    推荐阅读