beuiComboboxSubsequenceFilter function
Default source-compatible filter: a trimmed query must be a subsequence of the option value, label, or keywords (case-insensitive).
Implementation
bool beuiComboboxSubsequenceFilter(
String value,
String query,
List<String> keywords,
) {
final needle = query.trim().toLowerCase();
if (needle.isEmpty) return true;
final haystack = <String>[value, ...keywords].join(' ').toLowerCase();
var index = 0;
final needleRunes = needle.runes.toList();
for (final character in haystack.runes) {
if (character == needleRunes[index]) index++;
if (index == needle.length) return true;
}
return false;
}