ProviderElementBase<StateT> 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
Annotations

Constructors

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

Properties

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

Methods

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.
override
flush() → void
A utility for re-initializing a provider when needed.
getState() → Result<StateT>?
Obtains the current state, or null if the provider has yet to initialize.
invalidate(ProviderOrFamily provider) → void
Invalidates the state of the provider, destroying the state immediately and causing the provider to rebuild at some point in the future.
override
invalidateSelf() → void
Invalidates the state of the provider, causing it to refresh.
override
keepAlive() KeepAliveLink
Requests for the state of a provider to not be disposed when all the listeners of the provider are removed.
override
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.
override
listenSelf(void listener(StateT? previous, StateT next), {void onError(Object error, StackTrace stackTrace)?}) → void
Listens to changes on the value exposed by this provider.
override
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.
inherited
notifyListeners() → void
Notify dependents that this provider has changed.
override
onAddListener(void cb()) → void
A life-cycle for whenever a new listener is added to the provider.
override
onCancel(void cb()) → void
Add a listener to perform an operation when the last listener of the provider is removed.
override
onDispose(void listener()) → void
Adds a listener to perform an operation right before the provider is destroyed.
override
onRemoveListener(void cb()) → void
A life-cycle for whenever a listener is removed from the provider.
override
onResume(void cb()) → void
A life-cycle for when a provider is listened again after it was paused (and onCancel was triggered).
override
read<T>(ProviderListenable<T> provider) → T
Read the state associated with a provider, without listening to that provider.
override
readProviderElement<T>(ProviderBase<T> provider) ProviderElementBase<T>
Reads the state of a provider, potentially creating it in the process.
readSelf() → StateT
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.
override
runOnDispose() → void
Executes the Ref.onDispose listeners previously registered, then clear the list of listeners.
setState(StateT newState) → void
Update the exposed value of a provider and notify its listeners.
toString() String
A string representation of this object.
override
update(ProviderBase<StateT> newProvider) → void
Called when the override of a provider changes.
updateShouldNotify(StateT previous, StateT 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 element)) → void
Visit the ProviderElementBases that this provider is listening to.
visitChildren({required void elementVisitor(ProviderElementBase element), required void notifierVisitor(ProxyElementValueNotifier 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.
override

Operators

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