merge method

Map<K, V> merge(
  1. Map<K, V>? others
)

Merges the map in others with the current map.

If the same key is found, the value of others has priority.

Implementation

Map<K, V> merge(Map<K, V>? others) {
  others ??= const {};
  final res = <K, V>{};
  if (this != null) {
    for (final tmp in this!.entries) {
      res[tmp.key] = tmp.value;
    }
  }
  for (final tmp in others.entries) {
    res[tmp.key] = tmp.value;
  }
  return res;
}