remove method Null safety

bool remove (
  1. T item
)

Removes an item from the list.

This operation has constant time complexity.

Returns whether the item was present in the list.

Implementation

bool remove(T item) {
  final int? value = _map[item];
  if (value == null) {
    return false;
  }
  if (value == 1) {
    _map.remove(item);
  } else {
    _map[item] = value - 1;
  }
  return true;
}