mappedKeys<R> method

Map<R, V> mappedKeys<R>(
  1. R f(
    1. K key
    )
)

Maps the keys of the map using the provided function f.

Example usage:

void main() {
  Map<String, int> scores = {
    'John': 80,
    'Alice': 90,
    'Bob': 75,
    'Eve': 85,
  };

  Map<String, int> uppercaseKeys = scores.mappedKeys((key) => key.toUpperCase());
  print(uppercaseKeys); // Output: {JOHN: 80, ALICE: 90, BOB: 75, EVE: 85}
}

Implementation

Map<R, V> mappedKeys<R>(R Function(K key) f) => map((key, value) => MapEntry(f(key), value));