File tree Expand file tree Collapse file tree 1 file changed +13
-15
lines changed Expand file tree Collapse file tree 1 file changed +13
-15
lines changed Original file line number Diff line number Diff line change 11import 'dart:async' ;
2+ import 'dart:io' ;
23
4+ import 'package:android_intent/android_intent.dart' ;
35import 'package:flutter/material.dart' ;
46import 'package:gsy_github_app_flutter/common/localization/default_localizations.dart' ;
57import 'package:gsy_github_app_flutter/common/style/gsy_style.dart' ;
@@ -20,21 +22,17 @@ import 'package:gsy_github_app_flutter/widget/home_drawer.dart';
2022class HomePage extends StatelessWidget {
2123 static final String sName = "home" ;
2224
23- /// 单击提示退出
24- Future <bool > _dialogExitApp (BuildContext context) {
25- return showDialog (
26- context: context,
27- builder: (context) => new AlertDialog (
28- content: new Text (CommonUtils .getLocale (context).app_back_tip),
29- actions: < Widget > [
30- new FlatButton (onPressed: () => Navigator .of (context).pop (false ), child: new Text (CommonUtils .getLocale (context).app_cancel)),
31- new FlatButton (
32- onPressed: () {
33- Navigator .of (context).pop (true );
34- },
35- child: new Text (CommonUtils .getLocale (context).app_ok))
36- ],
37- ));
25+ /// 不退出
26+ Future <bool > _dialogExitApp (BuildContext context) async {
27+ if (Platform .isAndroid) {
28+ AndroidIntent intent = AndroidIntent (
29+ action: 'android.intent.action.MAIN' ,
30+ category: "android.intent.category.HOME" ,
31+ );
32+ await intent.launch ();
33+ }
34+
35+ return Future .value (false );
3836 }
3937
4038 _renderTab (icon, text) {
You can’t perform that action at this time.
0 commit comments