onAddListener method

RemoveListener onAddListener(
  1. 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:

Implementation

RemoveListener onAddListener(void Function() cb) {
  _throwIfInvalidUsage();

  final list = _onAddListeners ??= [];
  list.add(cb);

  return () => list.remove(cb);
}