clear method Null safety

void clear(
  1. {bool notifyChanges = true}
)

Removes all entries from the map.

After this, the map is empty.

final planets = <int, String>{1: 'Mercury', 2: 'Venus', 3: 'Earth'};
planets.clear(); // {}

Implementation

void clear({bool notifyChanges = true}) {
  final stateChangedEvent =
      EmpireStateChanged(<K, V>{}, _value, propertyName: propertyName);

  _value.clear();

  if (notifyChanges) {
    _viewModel.notifyChanges([stateChangedEvent]);
  }
}