clear method

  1. @override
void clear()
override

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

@override
void clear() {
  if (null is V) {
    updateAll((key, value) => null as V);
  } else {
    keys.forEach(remove);
  }
  // if Key contains default value
  // else if (this case IndexMap<Field, V> map when map.keys.every((key) => key.defaultValue != null)) {
  //   map.updateAll((key, value) => key.defaultValue as V);
  // }
  // throw UnsupportedError('IndexMap default clear operation not defined');
}