deepReplaceMapValues<T> function

void deepReplaceMapValues<T>(
  1. Map? map,
  2. ValueFilter filter,
  3. ValueReplacer replacer
)

Replaces values applying replacer to values that matches filter.

Implementation

void deepReplaceMapValues<T>(
    Map? map, ValueFilter filter, ValueReplacer replacer) {
  if (map == null || map.isEmpty) return;

  for (var entry in map.entries) {
    var k = entry.key;
    var v = entry.value;
    if (filter(map, k, v)) {
      map[k] = replacer(map, k, v);
    } else {
      map[k] = deepReplaceValues(v, filter, replacer);
    }
  }
}