associateTo<K, V> method
生成一个包含由 transform 函数提供的 MapEntry 的Map映射,然后追加到 destination中并返回。
举例:
final map = {'key': 0};
[1, 2, 3].associateTo(map, (e) => MapEntry('key_$e', e * 100)); // {'key': 0, 'key_1': 100, 'key_2': 200, 'key_3': 300}
Implementation
Map<K, V> associateTo<K, V>(Map<K, V> destination, MapEntry<K, V> Function(E element) transform) {
final temp = Map.fromEntries(map(transform));
destination.addAll(temp);
return destination;
}