FutureProvider<T> class

A FutureProvider allows you to watch a Future in your widgets. The value is cached and only fetched once.

Usage: final myProvider = FutureProvider((ref) async { return await fetchApi(); }

Example use cases:

  • fetch static data from an API (that does not change)
  • fetch device information (that does not change)
Implemented types

Constructors

FutureProvider(Future<T> _builder(WatchableRef ref), {ProviderChangedCallback<AsyncValue<T>>? onChanged, String describeState(AsyncValue<T> state)?, String? debugLabel, bool debugVisibleInGraph = true})

Properties

customDebugLabel → String?
A custom label used by debug tools.
finalinherited
debugLabel → String
A label to be used in debug messages and by the RefenaTracingPage.
no setterinherited
debugVisibleInGraph → bool
Set this flag to false to hide the provider from the RefenaGraphPage. By default, all providers are visible in the graph. However, some providers add unnecessary noise.
finalinherited
hashCode → int
The hash code for this object.
no setterinherited
provider → BaseProvider<FutureProviderNotifier<T>, AsyncValue<T>>
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

getActualProvider(BaseNotifier<Object?> notifier) → FutureProvider<T>
inherited
getSelectedState(FutureProviderNotifier<T> notifier, AsyncValue<T> state) → AsyncValue<T>
The default behavior to return the whole state when using ref.watch(provider).
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
overrideWithFuture(Future<T> builder(Ref ref)) → ProviderOverride<FutureProviderNotifier<T>, AsyncValue<T>> Initialization
Overrides the future.
select<R>(R selector(AsyncValue<T> state)) → SelectedWatchable<FutureProviderNotifier<T>, AsyncValue<T>, R>
Used for ref.watch(provider.select(...)). Select a part of the state.
inherited
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
Subclasses should not override this method. It is used internally by RefenaContainer to map a provider to a state.
inherited

Static Methods

family<T, P>(FutureFamilyBuilder<T, P> future, {String describeState(AsyncValue<T> state)?, String? debugLabel, bool debugVisibleInGraph = true}) → FutureFamilyProvider<T, P>
A shorthand for FutureFamilyProvider.