Flutter退出App的方法一般有两种

 

①SystemNavigator.pop 推荐

 

 

 

onTap: () async {

              await pop();

            },

static Future<void> pop() async {

    await SystemChannels.platform.invokeMethod('SystemNavigator.pop');

  }

 

 

别忘了引用

 

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

相关文章:

  • 2022-12-23
  • 2021-11-25
  • 2022-03-10
  • 2022-02-03
  • 2022-12-23
  • 2022-12-23
  • 2021-07-28
猜你喜欢
  • 2022-12-23
  • 2021-12-04
  • 2021-12-19
  • 2021-10-08
  • 2021-06-29
  • 2021-11-14
  • 2022-12-23
相关资源
相似解决方案