mergeWith method

Map<K, V> mergeWith(
  1. Map<K, V> other,
  2. V resolve(
    1. V a,
    2. V b
    )
)

Implementation

Map<K, V> mergeWith(Map<K, V> other, V Function(V a, V b) resolve) {
  if (this == null) return other;
  final result = Map<K, V>.from(this!);
  other.forEach((key, value) {
    result[key] = result.containsKey(key)
        ? resolve(result[key] as V, value)
        : value;
  });
  return result;
}