filter method
Filters the list of all options based on a query - the list of current selections is also provided.
Implementation
Future<List<T>> filter(
String? query, List currentSelections, int limit) async {
final List<T> options = await this.listAllOptions(150);
if (query.isNullOrBlank) return options;
return FullTextSearch<T>(
term: query!,
items: options.where((t) => !currentSelections.contains(t)).toList(),
isMatchAll: true,
isStartsWith: false,
limit: limit,
tokenize: (value) {
final KeyedOption<K, T> option = toOption(value)!;
return [
option.label,
for (final _ in (option.subtitle ?? const []))
if (_ != null) "$_",
...?option.extraTokens,
].whereNotBlank();
},
).findResults();
}