getEntryIgnoreCase<V> function

MapEntry<String, V?>? getEntryIgnoreCase<V>(
  1. Map<String, V?> map,
  2. String? key
)

Gets a map entry ignoring key case.

Implementation

MapEntry<String, V?>? getEntryIgnoreCase<V>(Map<String, V?> map, String? key) {
  if (key == null) return null;
  var val = map[key];
  if (val != null) return MapEntry(key, val);

  var keyLC = key.toLowerCase();

  for (var k in map.keys) {
    if (k.toLowerCase() == keyLC) {
      var value = map[k];
      return MapEntry<String, V?>(k, value);
    }
  }

  return null;
}