onAddListener method
RemoveListener
onAddListener(
- void cb()
A life-cycle for whenever a new listener is added to the provider.
Returns a function which can be called to remove the listener.
See also:
- onRemoveListener, for when a listener is removed
Implementation
RemoveListener onAddListener(void Function() cb) {
_throwIfInvalidUsage();
final list = _onAddListeners ??= [];
list.add(cb);
return () => list.remove(cb);
}