From e516dd3267cf58536f6e80af09afce84b812cb57 Mon Sep 17 00:00:00 2001 From: open-trade Date: Fri, 20 Nov 2020 00:29:59 +0800 Subject: [PATCH] skip return key of dialog --- flutter_hbb/lib/common.dart | 14 ++++++++------ flutter_hbb/lib/remote_page.dart | 10 +++++----- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/flutter_hbb/lib/common.dart b/flutter_hbb/lib/common.dart index 43de33e3e..55c65825b 100644 --- a/flutter_hbb/lib/common.dart +++ b/flutter_hbb/lib/common.dart @@ -53,12 +53,14 @@ Future showAlertDialog( _hasDialog = true; var dialog = StatefulBuilder(builder: (context, setState) { var widgets = build(setState); - return AlertDialog( - title: widgets.item1, - contentPadding: const EdgeInsets.all(20.0), - content: widgets.item2, - actions: widgets.item3, - ); + return WillPopScope( + onWillPop: () async => false, + child: AlertDialog( + title: widgets.item1, + contentPadding: const EdgeInsets.all(20.0), + content: widgets.item2, + actions: widgets.item3, + )); }); await showDialog( context: context, diff --git a/flutter_hbb/lib/remote_page.dart b/flutter_hbb/lib/remote_page.dart index 8f881474a..36a24b972 100644 --- a/flutter_hbb/lib/remote_page.dart +++ b/flutter_hbb/lib/remote_page.dart @@ -21,7 +21,7 @@ class RemotePage extends StatefulWidget { // https://github.com/hanxu317317/flutter_plan_demo/blob/master/lib/src/enter.dart class _RemotePageState extends State { Timer _interval; - bool _show_bar = true; + bool _showBar = true; @override void initState() { @@ -68,16 +68,16 @@ class _RemotePageState extends State { // MediaQuery.of(context).size.height; EasyLoading.instance.loadingStyle = EasyLoadingStyle.light; return Scaffold( - floatingActionButton: _show_bar + floatingActionButton: _showBar ? null : FloatingActionButton( mini: true, child: Icon(Icons.expand_less), backgroundColor: MyTheme.accent50, onPressed: () { - setState(() => _show_bar = !_show_bar); + setState(() => _showBar = !_showBar); }), - bottomNavigationBar: _show_bar + bottomNavigationBar: _showBar ? BottomAppBar( color: MyTheme.accent, child: Row( @@ -117,7 +117,7 @@ class _RemotePageState extends State { color: Colors.white, icon: Icon(Icons.expand_more), onPressed: () { - setState(() => _show_bar = !_show_bar); + setState(() => _showBar = !_showBar); }), ], ),