listenSelf method

  1. @protected
RemoveListener listenSelf(
  1. void listener(
    1. StateT? previous,
    2. StateT next
    ), {
  2. void onError(
    1. Object error,
    2. StackTrace stackTrace
    )?,
})

Listens to changes on the value exposed by this provider.

The listener will be called immediately after the provider completes building.

As opposed to Ref.listen, the listener will be called even if updateShouldNotify returns false, meaning that the previous and new value can potentially be identical.

Returns a function which can be called to remove the listener.

Implementation

@protected
RemoveListener listenSelf(
  void Function(StateT? previous, StateT next) listener, {
  void Function(Object error, StackTrace stackTrace)? onError,
}) {
  return $ref.listenSelf(listener, onError: onError);
}