mapKeys<T> method

Map<T, V> mapKeys<T>(
  1. T convert(
    1. K key,
    2. V value
    )
)

Returns a new map where the key of every entry in this map is transformed by the given convert function.

In case if any two entries are mapped to the equal keys, the value of the latter one will overwrite the value associated with the former one.

The new Map preserves the entry iteration order of the this Map.

Implementation

Map<T, V> mapKeys<T>(T Function(K key, V value) convert) {
  return map((key, value) => MapEntry(convert(key, value), value));
}