diff method

Map<K, V> diff(
  1. Map<K, V> other
)

Returns entries in this map whose values differ from other. Includes keys present in this map but absent in other.

{'a': 1, 'b': 2}.diff({'a': 1, 'b': 3}) // {'b': 3}

Implementation

Map<K, V> diff(Map<K, V> other) {
  final result = <K, V>{};
  for (final e in other.entries) {
    if (!containsKey(e.key) || this[e.key] != e.value) {
      result[e.key] = e.value;
    }
  }
  return result;
}