updateAll method

  1. @override
void updateAll(
  1. V update(
    1. K key,
    2. V value
    )
)

Updates all values.

Iterates over all entries in the map and updates them with the result of invoking update.

final terrestrial = <int, String>{1: 'Mercury', 2: 'Venus', 3: 'Earth'};
terrestrial.updateAll((key, value) => value.toUpperCase());
print(terrestrial); // {1: MERCURY, 2: VENUS, 3: EARTH}

Implementation

@override
void updateAll(V Function(K key, V value) update) {
  bool shouldNotify = false;
  for (final entry in super.entries) {
    final newValue = update(entry.key, entry.value);
    shouldNotify = shouldNotify || newValue != entry.value;
    super[entry.key] = newValue;
  }
  if (shouldNotify) {
    notifyListeners();
  }
}