addOnLastListenerRemovedCallback method Null safety

void addOnLastListenerRemovedCallback(
  1. VoidCallback callback
)

Adds a callback to call when removeListener results in an empty list of listeners and there are no keepAlive handles outstanding.

This callback will never fire if removeListener is never called.

Implementation

void addOnLastListenerRemovedCallback(VoidCallback callback) {
  assert(callback != null);
  _checkDisposed();
  _onLastListenerRemovedCallbacks.add(callback);
}