getSuggestions method
List<T>
getSuggestions(
- List<
T> suggestions, - Comparator<
T> ? sorter, - Filter<
T> ? filter, - int maxAmount,
- String? query,
Implementation
List<T> getSuggestions(List<T> suggestions, Comparator<T>? sorter,
Filter<T>? filter, int maxAmount, String? query) {
if (null == query || query.length < minLength) {
return [];
}
suggestions = suggestions.where((item) => filter!(item, query)).toList();
suggestions.sort(sorter);
if (suggestions.length > maxAmount) {
suggestions = suggestions.sublist(0, maxAmount);
}
return suggestions;
}