remove method
Removes key and its associated value, if present, from the map.
Returns the value associated with key before it was removed.
Returns null if key was not in the map.
Note that some maps allow null as a value,
so a returned null value doesn't always mean that the key was absent.
final terrestrial = <int, String>{1: 'Mercury', 2: 'Venus', 3: 'Earth'};
final removedValue = terrestrial.remove(2); // Venus
print(terrestrial); // {1: Mercury, 3: Earth}
Implementation
@override
V remove(covariant K key) {
if (null is V) {
final value = _valuesBuffer[key.index];
_valuesBuffer[key.index] = null as V;
return value;
}
// else if (defaultValue != null) // throws via noSuchMethod
// {}
throw UnsupportedError('IndexMap default remove operation not defined');
}