mergeWith method
Merges this map with other. For duplicate keys, resolve determines
the winner (defaults to other's value).
Implementation
Map<K, V> mergeWith(
Map<K, V> other, {
V Function(V existing, V incoming)? resolve,
}) {
final result = Map<K, V>.from(this);
for (final e in other.entries) {
result[e.key] = (resolve != null && result.containsKey(e.key))
? resolve(result[e.key] as V, e.value)
: e.value;
}
return result;
}