ProviderContainer class final Core
An object that stores the state of the providers and allows overriding the behavior of a specific provider.
If you are using Flutter, you do not need to care about this object
(outside of testing), as it is implicitly created for you by ProviderScope.
Inside tests, consider using ProviderContainer.test. This will automatically dispose the container at the end of the test.
- Annotations
-
- @publicInRiverpodAndCodegen
Constructors
-
ProviderContainer({ProviderContainer? parent, List<
Override> overrides = const [], List<ProviderObserver> ? observers, @internal void onError(Object error, StackTrace stackTrace)?, Retry? retry}) - An object that stores the state of the providers and allows overriding the behavior of a specific provider.
-
ProviderContainer.test({ProviderContainer? parent, List<
Override> overrides = const [], List<ProviderObserver> ? observers, Retry? retry}) -
An automatically disposed ProviderContainer.
factory
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
-
observers
→ List<
ProviderObserver> -
The list of observers attached to this container.
final
- retry → Retry?
-
The default retry logic used by providers associated to this container.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
debugReassemble(
) → void -
Executes
ProviderElement.debugReassembleon all the providers. -
dispose(
) → void - Release all the resources associated with this ProviderContainer.
-
exists(
ProviderBase< Object?> provider) → bool - Determines whether a provider is initialized or not.
-
invalidate(
ProviderOrFamily provider, {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.
-
listen<
StateT> (ProviderListenable< StateT> provider, void listener(StateT? previous, StateT next), {bool fireImmediately = false, bool weak = false, void onError(Object error, StackTrace stackTrace)?}) → ProviderSubscription<StateT> -
Listen to a provider and call
listenerwhenever its value changes. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
pump(
) → Future< void> - Awaits for providers to rebuild/be disposed and for listeners to be notified.
-
read<
StateT> (ProviderListenable< StateT> provider) → StateT - Reads a provider without listening to it and returns the currently exposed value.
-
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.
override
-
updateOverrides(
List< Override> overrides) → void - Updates the list of provider overrides.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited