From 6c18645561df88b4eb653ec0eeb5db80fc603b5a Mon Sep 17 00:00:00 2001 From: open-trade Date: Wed, 18 Aug 2021 02:01:03 +0800 Subject: [PATCH] fix input password dialog bug --- flutter_hbb/lib/common.dart | 6 +++++- flutter_hbb/lib/remote_page.dart | 4 +++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/flutter_hbb/lib/common.dart b/flutter_hbb/lib/common.dart index 2d43d5957..82c3c754a 100644 --- a/flutter_hbb/lib/common.dart +++ b/flutter_hbb/lib/common.dart @@ -29,6 +29,7 @@ final ButtonStyle flatButtonStyle = TextButton.styleFrom( ), ); +void Function() loadingCancelCallback = null; void showLoading(String text, BuildContext context) { if (_hasDialog && context != null) { Navigator.pop(context); @@ -52,7 +53,10 @@ void showLoading(String text, BuildContext context) { child: TextButton( style: flatButtonStyle, onPressed: () { - dismissLoading(); + // with out loadingCancelCallback, we can see unexpected input password + // dialog shown in home, no clue why, so use this as workaround + // why no such issue on android? + if (loadingCancelCallback != null) loadingCancelCallback(); Navigator.pop(context); }, child: Text(Translator.call('Cancel'), diff --git a/flutter_hbb/lib/remote_page.dart b/flutter_hbb/lib/remote_page.dart index 2ad51e599..3345d6219 100644 --- a/flutter_hbb/lib/remote_page.dart +++ b/flutter_hbb/lib/remote_page.dart @@ -52,18 +52,20 @@ class _RemotePageState extends State { Timer.periodic(Duration(milliseconds: 30), (timer) => interval()); }); Wakelock.enable(); + loadingCancelCallback = () => _interval.cancel(); } @override void dispose() { _focusNode.dispose(); - super.dispose(); FFI.close(); + loadingCancelCallback = null; _interval.cancel(); _timer?.cancel(); dismissLoading(); SystemChrome.setEnabledSystemUIOverlays(SystemUiOverlay.values); Wakelock.disable(); + super.dispose(); } void resetTool() {