removeListener method

  1. @override
bool removeListener(
  1. K key
)
override

Returns true if key was used for a listener and therefore successfully removed.

Returns false, if there was no listener associated with key.

Implementation

@override
bool removeListener(K key) {
  final containedKey = _listeners.containsKey(key);

  _listeners = Map.of({
    for (final item in _listeners.entries)
      // Only add listeners if their key is unequal to the
      // key of the listener you want to remove.
      if (item.key != key) item.key: item.value,
  });

  return containedKey;
}