listen method
ProviderSubscription<Listened>
listen({
- void mayHaveChanged(
- ProviderSubscription<
Listened> sub
- ProviderSubscription<
- void didChange(
- ProviderSubscription<
Listened> sub
- ProviderSubscription<
Listen to this provider.
See also:
- ProviderContainer.listen, which internally calls this method
- ProviderReference.watch, which makes a provider listen to another provider.
Implementation
ProviderSubscription<Listened> listen({
void Function(ProviderSubscription<Listened> sub)? mayHaveChanged,
void Function(ProviderSubscription<Listened> sub)? didChange,
}) {
late ProviderSubscription<Listened> sub;
final entry = _Listener<Listened>(
mayHaveChanged: mayHaveChanged == null ? null : () => mayHaveChanged(sub),
didChange: didChange == null ? null : () => didChange(sub),
element: this,
);
_listeners.add(entry);
return sub = ProviderSubscription._(entry);
}