mapRemoveValue<K, V> static method
Removes all occurrences of value from the list at key within map.
Uses an immutable approach: creates a new filtered list rather than mutating the existing one.
Example:
final map = <String, List<int>>{'scores': [100, 200, 100]};
MapExtensions.mapRemoveValue(map: map, key: 'scores', value: 100); // {'scores': [200]}
Implementation
static void mapRemoveValue<K, V>({
required Map<K, List<V>> map,
required K key,
required V value,
}) {
if (value == null) return;
// ignore: saropa_lints/avoid_parameter_mutation -- function is designed to mutate the map parameter
map.update(
key,
(List<V> list) => list.where((V v) => v != value).toList(),
ifAbsent: () => <V>[],
);
}