remove method

V? remove(
  1. K key
)

Removes the association for key, if present.

Detaches the wrapper from the internal Finalizer to prevent the callback from firing in the future.

Returns the previously associated value, or null if none existed.

Implementation

V? remove(K key) {
  final wrapper = getWrapper(key);
  if (wrapper != null) {
    _finalizer.detach(wrapper);
    return wrapper.value;
  }
  return null;
}