map<K2, V2> method Null safety

Map<K2, V2> map <K2, V2>(
  1. MapEntry<K2, V2> transform(
    1. K key,
    2. V value
    )
)
override

Returns a new map where all entries of this map are transformed by the given f function.

Implementation

Map<K2, V2> map<K2, V2>(MapEntry<K2, V2> transform(K key, V value)) {
  var result = <K2, V2>{};
  for (var key in this.keys) {
    var entry = transform(key, this[key] as V);
    result[entry.key] = entry.value;
  }
  return result;
}