updateAndJoin method

Map<K, V> updateAndJoin(
  1. Map<K, V>? map
)

Returns a new map with two map join if key already exist then passing map value override

Implementation

Map<K, V> updateAndJoin(Map<K, V>? map) {
  if (isNullOrEmpty) return map ?? {};
  if (map.isNullOrEmpty) return this ?? {};
  final newMap = this!;
  for (final key in map!.keys) {
    if (this!.containsKey(key)) {
      newMap[key] = map[key] as V;
    } else {
      newMap.addAll({key: map[key] as V});
    }
  }
  return map;
}