felixmccuaig/flutter-autocomplete-textfield

How to get all elements of the suggestions list as suggestion

Closed this issue · 3 comments

First of all, thank you very much for this library.

Just a little question.

How can i get all elements of the suggestions list as suggestion when the input text is empty (for example when first tap on the input area) ?

Same question here, did you resolve this? Does this library provide this feature?

Maybe adding a property to allow users to display all entries when the filter is empty

bool displaySuggestionsIfEmpty = false;

List<T> getSuggestions(List<T> suggestions, Comparator<T> sorter, 
                        Filter<T> filter, int maxAmount, String query) {

    if (query == "") {
        if(this.displaySuggestionsIfEmpty){
            return suggestions;
        }
        return [];
    }
    suggestions.sort(sorter);
    suggestions = suggestions.where((item) => filter(item, query)).toList();
    if (suggestions.length > maxAmount) {
        suggestions = suggestions.sublist(0, maxAmount);
    }
    return suggestions;
}

Something like this should work
itemFilter: (suggestion, input) { return suggestion.name.toLowerCase().startsWith(input.toLowerCase()) || input == ""; }, minLength: 0,