mapKeys<K2> method

Map<K2, V> mapKeys<K2>(
  1. K2 transform(
    1. K key,
    2. V value
    )
)

Transforms the keys of the map.

Example:

print({'a': 1}.mapKeys((k, v) => k.toUpperCase())); // {'A': 1}

Implementation

Map<K2, V> mapKeys<K2>(K2 Function(K key, V value) transform) {
  return Map.fromEntries(entries.map((e) => MapEntry(transform(e.key, e.value), e.value)));
}