listenManual<StateT> abstract method
ProviderSubscription<StateT>
listenManual<StateT>(
- ProviderListenable<
StateT> provider, - void listener(
- StateT? previous,
- StateT next
- void onError(
- Object error,
- StackTrace stackTrace
- bool fireImmediately,
Listen to a provider and call listener
whenever its value changes.
As opposed to listen, listenManual is not safe to use within the build
method of a widget.
Instead, listenManual is designed to be used inside State.initState or
other State life-cycles.
listenManual returns a ProviderSubscription which can be used to stop listening to the provider, or to read the current value exposed by the provider.
It is not necessary to call ProviderSubscription.close inside State.dispose. When the widget that calls listenManual is disposed, the subscription will be disposed automatically.
Implementation
ProviderSubscription<StateT> listenManual<StateT>(
ProviderListenable<StateT> provider,
void Function(StateT? previous, StateT next) listener, {
void Function(Object error, StackTrace stackTrace)? onError,
bool fireImmediately,
});