searchMap<K, V> static method
- required Iterable<
Map< items,K, V> > - required dynamic searchTerms,
- Iterable<
K> keys = const [], - int levenshteinDistance = 0,
- bool allIfEmpty = true,
- bool ignoreCase = true,
- bool ignoreDiacritics = true,
- bool ignoreWordSplitters = true,
- bool splitCamelCase = true,
- bool useWildcards = false,
- int maxResults = 0,
- int minChars = 0,
Searches for JsonRow objects in the iterable based on a search term and specified keys.
The searchTerms
parameter is the term to search for. Can be a string or a list of strings.
The keys
parameter is a list of keys to search on. If empty, all keys in the JsonRow objects will be used.
The levenshteinDistance
parameter is the maximum allowed Levenshtein distance between the search term and a value in the JsonRow objects.
The allIfEmpty
parameter determines whether to return all JsonRow objects if the search term is empty.
Returns an iterable of JsonRow objects that match the search criteria.
Implementation
static Iterable<Map<K, V>> searchMap<K, V>({
required Iterable<Map<K, V>> items,
required dynamic searchTerms,
Iterable<K> keys = const [],
int levenshteinDistance = 0,
bool allIfEmpty = true,
bool ignoreCase = true,
bool ignoreDiacritics = true,
bool ignoreWordSplitters = true,
bool splitCamelCase = true,
bool useWildcards = false,
int maxResults = 0,
int minChars = 0,
}) {
if (keys.isEmpty) {
keys = items.expand((e) => e.keys).distinct().toList();
}
return search(
items: items,
searchTerms: searchTerms,
searchOn: (row) => [
for (var k in keys)
if (row[k] != null) row[k]!
],
levenshteinDistance: levenshteinDistance,
allIfEmpty: allIfEmpty,
ignoreCase: ignoreCase,
ignoreDiacritics: ignoreDiacritics,
ignoreWordSplitters: ignoreWordSplitters,
maxResults: maxResults,
minChars: minChars,
splitCamelCase: splitCamelCase,
useWildcards: useWildcards,
);
}