modMap<K, V> static method
Map<K, V>
modMap<
K, V>( - Map<K, V> initial,
- Map<K, V>? add,
- Iterable<K>? removeKeys,
- bool whereKeys(
- K
)?,
- Iterable<V>? removeValues,
- bool whereValues(
- V
)?,
)
Implementation
static Map<K,V> modMap<K,V>(Map<K,V> initial, Map<K,V>? add, Iterable<K>? removeKeys, bool Function(K)? whereKeys, Iterable<V>? removeValues, bool Function(V)? whereValues){
if(add != null || removeKeys != null || whereKeys != null || removeValues != null || whereValues != null){
Map<K,V> copy = initial;
if(add != null){
copy.addAll(add);
}
if(removeKeys != null){
for(K key in removeKeys){
copy.remove(key);
}
}
if(whereKeys != null){
copy.removeWhere((k, v) => whereKeys(k));
}
if(removeValues != null){
for(V value in removeValues){
copy.removeWhere((k, v) => v == value);
}
}
if(whereValues != null){
copy.removeWhere((k, v) => whereValues(v));
}
return copy;
}
return initial;
}