From 454882e994a9243fea7e5f474a4d94d10e7a3ddc Mon Sep 17 00:00:00 2001 From: dragon Date: Sat, 11 Nov 2023 22:49:28 +0100 Subject: [PATCH] updated autocomplete --- lib/interface/widgets/autocomplete.dart | 23 +++++++++++++++-------- pubspec.lock | 11 ++++++----- pubspec.yaml | 5 +++++ 3 files changed, 26 insertions(+), 13 deletions(-) diff --git a/lib/interface/widgets/autocomplete.dart b/lib/interface/widgets/autocomplete.dart index 88c4c04f4..4f5cba0b3 100644 --- a/lib/interface/widgets/autocomplete.dart +++ b/lib/interface/widgets/autocomplete.dart @@ -39,15 +39,13 @@ class AutocompleteTextField extends StatelessWidget { return TypeAheadField( direction: direction ?? AxisDirection.up, hideOnEmpty: true, - hideOnError: true, - hideKeyboard: readOnly, - keepSuggestionsOnSuggestionSelected: true, - suggestionsBoxDecoration: hasFab - ? const SuggestionsBoxDecoration( + hideOnSelect: false, + suggestionsDecoration: hasFab + ? const SuggestionsDecoration( shape: AutocompleteCutout(), clipBehavior: Clip.antiAlias, ) - : const SuggestionsBoxDecoration(), + : const SuggestionsDecoration(), textFieldConfiguration: TextFieldConfiguration( controller: controller, autofocus: true, @@ -59,9 +57,9 @@ class AutocompleteTextField extends StatelessWidget { InputDecoration(labelText: labelText), onSubmitted: submit, textInputAction: textInputAction ?? TextInputAction.search, + readOnly: readOnly, ), - loadingBuilder: (context) => const SizedBox(), - noItemsFoundBuilder: (context) => const ListTile( + loadingBuilder: (context) => const ListTile( title: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ @@ -69,6 +67,15 @@ class AutocompleteTextField extends StatelessWidget { ], ), ), + errorBuilder: (context, error) => const Column( + mainAxisSize: MainAxisSize.min, + children: [ + IconMessage( + icon: Icon(Icons.error), + title: Text('Failed to load suggestions'), + ), + ], + ), onSuggestionSelected: onSuggestionSelected, itemBuilder: itemBuilder, suggestionsCallback: suggestionsCallback, diff --git a/pubspec.lock b/pubspec.lock index ee27a2f38..4646593f1 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -563,11 +563,12 @@ packages: flutter_typeahead: dependency: "direct main" description: - name: flutter_typeahead - sha256: b9942bd5b7611a6ec3f0730c477146cffa4cd4b051077983ba67ddfc9e7ee818 - url: "https://pub.dev" - source: hosted - version: "4.8.0" + path: "." + ref: cb34bae8e2094ed7e8268e18f514071f6f44826b + resolved-ref: cb34bae8e2094ed7e8268e18f514071f6f44826b + url: "https://github.com/clragon/flutter_typeahead.git" + source: git + version: "5.0.0" flutter_web_plugins: dependency: transitive description: flutter diff --git a/pubspec.yaml b/pubspec.yaml index f0d06c46c..237db4e98 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -93,6 +93,11 @@ dependency_overrides: git: url: https://github.com/clragon/infinite_scroll_pagination.git ref: 4.1.0-dev.2 + flutter_typeahead: + # path: ../flutter_typeahead + git: + url: https://github.com/clragon/flutter_typeahead.git + ref: cb34bae8e2094ed7e8268e18f514071f6f44826b collection: 1.18.0 dev_dependencies: