upsertAt method

Map<K, V> Function(K key, V value) upsertAt(
  1. Eq<K> eq
)

Insert or replace a key/value pair in a Map.

Implementation

Map<K, V> Function(K key, V value) upsertAt(Eq<K> eq) => (K key, V value) {
      final newMap = {...this};
      newMap.addEntries([MapEntry(key, value)]);
      return newMap.modifyAtIfPresent(eq)(key, (_) => value);
    };