findKeyEntry<K, V> function
Finds in map
a entry that has one of keys
.
ignoreCase
If true
ignores the case of the keys.
Implementation
MapEntry<K, V?>? findKeyEntry<K, V>(Map? map, List<K>? keys,
[bool ignoreCase = false]) {
if (map == null || keys == null || map.isEmpty || keys.isEmpty) return null;
if (ignoreCase) {
for (var key in keys) {
if (map.containsKey(key)) {
var value = map[key] as V?;
return MapEntry<K, V?>(key, value);
}
var keyLC = key.toString().toLowerCase();
for (var k in map.keys.whereType<K>()) {
if (k.toString().toLowerCase() == keyLC) {
var value = map[k] as V?;
return MapEntry<K, V?>(k, value);
}
}
}
} else {
for (var key in keys) {
if (map.containsKey(key)) {
var value = map[key] as V?;
return MapEntry<K, V?>(key, value);
}
}
}
return null;
}