Skip to content

Commit

Permalink
Merge pull request #308 from lukaszdebowski/allow-for-null-suggestions
Browse files Browse the repository at this point in the history
Allow suggestionsCallback to return null
  • Loading branch information
sjmcdowall authored May 7, 2021
2 parents b1cdc6b + 48a876a commit 5ddd68a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions lib/cupertino_flutter_typeahead.dart
Original file line number Diff line number Diff line change
Expand Up @@ -887,7 +887,7 @@ class _SuggestionsListState<T> extends State<_SuggestionsList<T>>
this._error = null;
});

Iterable<T> suggestions = [];
Iterable<T>? suggestions;
Object? error;

try {
Expand All @@ -901,7 +901,8 @@ class _SuggestionsListState<T> extends State<_SuggestionsList<T>>
// 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);
Expand Down
5 changes: 3 additions & 2 deletions lib/flutter_typeahead.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1075,7 +1075,7 @@ class _SuggestionsListState<T> extends State<_SuggestionsList<T>>
this._error = null;
});

Iterable<T> suggestions = [];
Iterable<T>? suggestions;
Object? error;

try {
Expand All @@ -1089,7 +1089,8 @@ class _SuggestionsListState<T> extends State<_SuggestionsList<T>>
// 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);
Expand Down

0 comments on commit 5ddd68a

Please sign in to comment.