addEntries 方法

void addEntries(
  1. Iterable<MapEntry<K, V>> entries
)
override

向此映射中添加 newEntries 中的所有键/值对。

如果 newEntries 中的键已在此映射中,则相应的值将被覆盖。

该操作等价于为迭代器中的每个 MapEntry 执行 this[entry.key] = entry.value

final planets = <int, String>{1: 'Mercury', 2: 'Venus',
  3: 'Earth', 4: 'Mars'};
final gasGiants = <int, String>{5: 'Jupiter', 6: 'Saturn'};
final iceGiants = <int, String>{7: 'Uranus', 8: 'Neptune'};
planets.addEntries(gasGiants.entries);
planets.addEntries(iceGiants.entries);
print(planets);
// {1: Mercury, 2: Venus, 3: Earth, 4: Mars, 5: Jupiter, 6: Saturn,
//  7: Uranus, 8: Neptune}

实现

void addEntries(Iterable<MapEntry<K, V>> entries) {
  _map.addEntries(entries);
}