copyFrom method

Map<K, V> copyFrom(
  1. Map<K, V> map
)

Convenient to get new key value from key value collection. map The collection of new keys to be obtained.

Implementation

Map<K, V> copyFrom(Map<K, V> map) {
  if (isEmpty) {
    return map;
  }
  if (map.isNotEmpty) {
    final Iterable<K> keys = map.keys;
    for (final K item in keys) {
      final V? itemValue = map[item];
      putIfAbsent(item, () => itemValue!);
    }
  }
  return this;
}