ProviderElementBase<State> class abstract

An internal class that handles the state of a provider.

This is what keeps track of the state of a provider, and notifies listeners when the state changes. It is also responsible for rebuilding the provider when one of its dependencies changes.

This class is not meant to be used directly and is an implementation detail of providers. Do not use.

Implemented types


ProviderElementBase(ProviderBase<State> _provider)
An internal class that handles the state of a provider.


container ProviderContainer
The ProviderContainer that owns this ProviderElementBase.
debugAssertDidSetStateEnabled bool
Whether the assert that prevents requireState from returning if the state was not set before is enabled.
hashCode int
The hash code for this object.
hasListeners bool
Whether this ProviderElementBase is currently listened to or not.
mounted bool
Whether the element was disposed or not
origin ProviderBase<Object?>
The provider associated with this ProviderElementBase, before applying overrides.
provider ProviderBase<State>
The provider associated with this ProviderElementBase, after applying overrides.
requireState → State
Read the current value of a provider and:
runtimeType Type
A representation of the runtime type of the object.


buildState() → void
Invokes create and handles errors.
create({required bool didChangeDependency}) → void
Initialize a provider.
debugReassemble() → void
A life-cycle executed when a hot-reload is performed.
dispose() → void
Release the resources associated to this ProviderElementBase.
exists(ProviderBase<Object?> provider) bool
Determines whether a provider is initialized or not.
flush() → void
A utility for re-initializing a provider when needed.
getState() → Result<State>?
Obtains the current state, or null if the provider has yet to initialize.
invalidate(ProviderOrFamily provider) → void
Invalidates the state of the provider, causing it to refresh.
invalidateSelf() → void
Invalidates the state of the provider, causing it to refresh.
listen<T>(ProviderListenable<T> listenable, void listener(T? previous, T value), {void onError(Object error, StackTrace stackTrace)?, bool fireImmediately = false, void onDependencyMayHaveChanged()?}) ProviderSubscription<T>
Listen to a provider and call listener whenever its value changes.
listenSelf(void listener(State? previous, State next), {void onError(Object error, StackTrace stackTrace)?}) → void
Listens to changes on the value exposed by this provider.
mayNeedDispose() → void
Life-cycle for when a listener is removed.
mount() → void
Called the first time a provider is obtained.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
notifyListeners() → void
Notify depedents that this provider has changed.
onAddListener(void cb()) → void
A life-cycle for whenever a new listener is added to the provider.
onCancel(void cb()) → void
Add a listener to perform an operation when the last listener of the provider is removed.
onDispose(void listener()) → void
Adds a listener to perform an operation right before the provider is destroyed.
onRemoveListener(void cb()) → void
A life-cycle for whenever a listener is removed from the provider.
onResume(void cb()) → void
A life-cycle for when a provider is listened again after it was paused (and onCancel was triggered).
read<T>(ProviderListenable<T> provider) → T
Read the state associated with a provider, without listening to that provider.
readProviderElement<T>(ProviderBase<T> provider) ProviderElementBase<T>
Reads the state of a provider, potentially creating it in the process.
readSelf() → State
Returns the currently exposed by a provider
refresh<T>(Refreshable<T> provider) → T
Forces a provider to re-evaluate its state immediately, and return the created value.
runOnDispose() → void
Executes the Ref.onDispose listeners previously registered, then clear the list of listeners.
setState(State newState) → void
Update the exposed value of a provider and notify its listeners.
toString() String
A string representation of this object.
update(ProviderBase<State> newProvider) → void
Called when the override of a provider changes.
updateShouldNotify(State previous, State next) bool
Called when a provider is rebuilt. Used for providers to not notify their listeners if the exposed value did not change.
visitAncestors(void visitor(ProviderElementBase<Object?> element)) → void
Visit the ProviderElementBases that this provider is listening to.
visitChildren({required void elementVisitor(ProviderElementBase<Object?> element), required void notifierVisitor(ProxyElementValueNotifier<Object?> element)}) → void
Visit the ProviderElements of providers that are listening to this element.
watch<T>(ProviderListenable<T> listenable) → T
Obtains the state of a provider and causes the state to be re-evaluated when that provider emits a new value.


operator ==(Object other) bool
The equality operator.