associate<K, V> method

Map<K, V> associate<K, V>(
  1. MapEntry<K, V> transform(
    1. E element
    )
)

返回一个包含由 transform 函数提供的 MapEntry 的Map映射。

举例:

[1, 2, 3].associate((e) => MapEntry('key_$e', e * 100)); // {'key_1': 100, 'key_2': 200, 'key_3': 300}

Implementation

Map<K, V> associate<K, V>(MapEntry<K, V> Function(E element) transform) {
  return Map.fromEntries(map(transform));
}