Ref class sealed Core

An object used by providers to interact with other providers and the life-cycles of the application.

See also:

  • read and watch, two methods that allow a provider to consume other providers.
  • onDispose, a method that allows performing a task when the provider is destroyed.
Annotations
  • @publicInRiverpodAndCodegen

Properties

container → ProviderContainer
The ProviderContainer that this provider is associated with.
no setter
hashCode → int
The hash code for this object.
no setterinherited
isFirstBuild → bool
Whether we're initializing this provider for the first time.
final
isPaused → bool
Whether this Ref is currently paused (no active, non-paused listeners).
no setter
isRefresh → bool
Whether the provider was recomputed without any dependency change.
no setter
isReload → bool
Whether the provider was recomputed after at least one dependency changed.
final
mounted → bool
Whether this Ref is still active.
no setter
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

exists(ProviderBase<Object?> provider) → bool
Determines whether a provider is initialized or not.
invalidate(ProviderOrFamily providerOrFamily, {bool asReload = false}) → void
Invalidates the state of the provider, destroying the state immediately and causing the provider to rebuild at some point in the future.
invalidateSelf({bool asReload = false}) → void
Invokes invalidate on itself.
keepAlive() → KeepAliveLink
Requests for the state of a provider to not be disposed when all the listeners of the provider are removed.
listen<StateT>(ProviderListenable<StateT> provider, void listener(StateT? previous, StateT next), {void onError(Object error, StackTrace stackTrace)?, bool weak = false, bool fireImmediately = false}) → ProviderSubscription<StateT>
Listen to a provider and call listener whenever its value changes.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
notifyListeners() → void
Notify dependents that this provider has changed.
onAddListener(void cb()) → RemoveListener
A life-cycle for whenever a new listener is added to the provider.
onCancel(void cb()) → RemoveListener
Add a listener to perform an operation when the last listener of the provider is removed.
onDispose(void listener()) → RemoveListener
Adds a listener to perform an operation right before the provider is destroyed.
onManualInvalidation(void cb()) → RemoveListener
A life-cycle for whenever this provider is manually invalidated, as opposed to automatic invalidation caused by dependency changes.
onRemoveListener(void cb()) → RemoveListener
A life-cycle for whenever a listener is removed from the provider.
onResume(void cb()) → RemoveListener
A life-cycle for when a provider is listened again after it was paused (and onCancel was triggered).
read<StateT>(ProviderListenable<StateT> listenable) → StateT
Read the state associated with a provider, without listening to that provider.
refresh<StateT>(Refreshable<StateT> refreshable) → StateT
Forces a provider to re-evaluate its state immediately, and return the created value.
toString() → String
A string representation of this object.
inherited
watch<StateT>(ProviderListenable<StateT> listenable) → StateT
Obtains the state of a provider and causes the state to be re-evaluated when that provider emits a new value.

Operators

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