mapValues<V2> method

Map<K, V2> mapValues<V2>(
  1. V2 transform(
    1. V value
    )
)

Transforms all the values in the map by applying a transform function.

Example:

final map = <int, int>{1: 1, 2: 2, 3: 3};
final transformed = map.mapValues((value) => value * 2);
print(transformed); // Output: <int, int>{1: 2, 2: 4, 3: 6}

Implementation

Map<K, V2> mapValues<V2>(V2 Function(V value) transform) =>
    Map<K, V2>.fromEntries(
      entries.map((e) => MapEntry(e.key, transform(e.value))),
    );