mapKeys<K2> method

Map<K2, V1> mapKeys<K2>(
  1. K2 mapper(
    1. K1 key
    )
)

Returns a new map with new keys and the same values.

Implementation

Map<K2, V1> mapKeys<K2>(K2 Function(K1 key) mapper) {
  return Map.fromEntries(
    entries.map((e) => MapEntry(mapper(e.key), e.value)),
  );
}