diff --git a/lib/cupertino_flutter_typeahead.dart b/lib/cupertino_flutter_typeahead.dart index 4ef4bfb7..eac52457 100644 --- a/lib/cupertino_flutter_typeahead.dart +++ b/lib/cupertino_flutter_typeahead.dart @@ -887,7 +887,7 @@ class _SuggestionsListState extends State<_SuggestionsList> this._error = null; }); - Iterable suggestions = []; + Iterable? suggestions; Object? error; try { @@ -901,7 +901,8 @@ class _SuggestionsListState extends State<_SuggestionsList> // if it wasn't removed in the meantime setState(() { double? animationStart = widget.animationStart; - if (error != null || suggestions.isEmpty) { + // allow suggestionsCallback to return null and not throw error here + if (error != null || suggestions?.isEmpty == true) { animationStart = 1.0; } this._animationController!.forward(from: animationStart); diff --git a/lib/flutter_typeahead.dart b/lib/flutter_typeahead.dart index a8fded9e..15568188 100644 --- a/lib/flutter_typeahead.dart +++ b/lib/flutter_typeahead.dart @@ -1075,7 +1075,7 @@ class _SuggestionsListState extends State<_SuggestionsList> this._error = null; }); - Iterable suggestions = []; + Iterable? suggestions; Object? error; try { @@ -1089,7 +1089,8 @@ class _SuggestionsListState extends State<_SuggestionsList> // if it wasn't removed in the meantime setState(() { double? animationStart = widget.animationStart; - if (error != null || suggestions.isEmpty) { + // allow suggestionsCallback to return null and not throw error here + if (error != null || suggestions?.isEmpty == true) { animationStart = 1.0; } this._animationController!.forward(from: animationStart);