From 2aa72ddcd65340c8095f803413546cfd43296bdf Mon Sep 17 00:00:00 2001 From: ok300 <106775972+ok300@users.noreply.github.com> Date: Wed, 11 Oct 2023 19:01:20 +0200 Subject: [PATCH 1/2] Don't show autosuggestions for empty input --- .../mnemonics/widgets/restore_form.dart | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/routes/initial_walkthrough/mnemonics/widgets/restore_form.dart b/lib/routes/initial_walkthrough/mnemonics/widgets/restore_form.dart index 7fb4b1542..bb5be38af 100644 --- a/lib/routes/initial_walkthrough/mnemonics/widgets/restore_form.dart +++ b/lib/routes/initial_walkthrough/mnemonics/widgets/restore_form.dart @@ -120,7 +120,12 @@ class RestoreFormPageState extends State { } FutureOr> _getSuggestions(pattern) { - var suggestionList = WORDLIST.where((item) => item.startsWith(pattern)).toList(); - return suggestionList.isNotEmpty ? suggestionList : List.empty(); + if (pattern.toString().isEmpty) { + return List.empty(); + } + else { + var suggestionList = WORDLIST.where((item) => item.startsWith(pattern)).toList(); + return suggestionList.isNotEmpty ? suggestionList : List.empty(); + } } } From e57958f75f22bf9f20631b11d0af695438afad38 Mon Sep 17 00:00:00 2001 From: ok300 <106775972+ok300@users.noreply.github.com> Date: Wed, 11 Oct 2023 19:02:25 +0200 Subject: [PATCH 2/2] Fix flicker: hide autosuggestion box while loading --- .../initial_walkthrough/mnemonics/widgets/restore_form.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/routes/initial_walkthrough/mnemonics/widgets/restore_form.dart b/lib/routes/initial_walkthrough/mnemonics/widgets/restore_form.dart index bb5be38af..5d000c19d 100644 --- a/lib/routes/initial_walkthrough/mnemonics/widgets/restore_form.dart +++ b/lib/routes/initial_walkthrough/mnemonics/widgets/restore_form.dart @@ -67,6 +67,7 @@ class RestoreFormPageState extends State { validator: (text) => _onValidate(context, text!), suggestionsCallback: _getSuggestions, hideOnEmpty: true, + hideOnLoading: true, autoFlipDirection: true, suggestionsBoxDecoration: const SuggestionsBoxDecoration( color: Colors.white, @@ -122,8 +123,7 @@ class RestoreFormPageState extends State { FutureOr> _getSuggestions(pattern) { if (pattern.toString().isEmpty) { return List.empty(); - } - else { + } else { var suggestionList = WORDLIST.where((item) => item.startsWith(pattern)).toList(); return suggestionList.isNotEmpty ? suggestionList : List.empty(); }