Skip to content

Commit a0606e7

Browse files
committed
调整返回键
1 parent b6f04ec commit a0606e7

File tree

1 file changed

+13
-15
lines changed

1 file changed

+13
-15
lines changed

lib/page/home_page.dart

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import 'dart:async';
2+
import 'dart:io';
23

4+
import 'package:android_intent/android_intent.dart';
35
import 'package:flutter/material.dart';
46
import 'package:gsy_github_app_flutter/common/localization/default_localizations.dart';
57
import 'package:gsy_github_app_flutter/common/style/gsy_style.dart';
@@ -20,21 +22,17 @@ import 'package:gsy_github_app_flutter/widget/home_drawer.dart';
2022
class 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) {

0 commit comments

Comments
 (0)