FutureProvider<T> class final

Provides the value of a Future: initialData until it completes, then what it completes with, the widgets that watch it rebuilt then.

The future is the one create makes, the first time the value is read unless lazy is false; or with FutureProvider.value one made elsewhere, listened to when this widget is placed in the tree, which a new widget may replace by another. An error the future completes with is replaced by what catchError returns for it; without one it is logged at LogLevel.error and the value stays.

Settings loaded as the app starts, the defaults until then:

FutureProvider(
  create: (context) => loadSettings(),
  initialData: const Settings(),
  child: app,
)
Inheritance

Constructors

FutureProvider({required Create<Future<T>?> create, required T initialData, Key? key, ErrorBuilder<T>? catchError, UpdateShouldNotify<T>? updateShouldNotify, bool? lazy, TransitionBuilder? builder, Widget? child})
Provides the value of the future create makes, initialData until it completes.
FutureProvider.value({required Future<T>? value, required T initialData, Key? key, ErrorBuilder<T>? catchError, UpdateShouldNotify<T>? updateShouldNotify, TransitionBuilder? builder, Widget? child})
Provides the value of value, a future made elsewhere, initialData until it completes.

Properties

builder → TransitionBuilder?
Builds the child below this provider, from the one given.
finalinherited
hashCode → int
The hash code for this object.
no setterinherited
key → Key?
Tells this widget apart from its siblings; see Key.
finalinherited
lazy → bool
Whether the value is made only when it is first read; else when this widget is placed in the tree.
finalinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

build(BuildContext context) → Widget
Describes this part of the interface; called when the widget is placed in the tree, whenever its parent gives it a new widget, and when its element is marked dirty.
inherited
buildWithChild(BuildContext context, Widget? child) → Widget
What this widget shows around child.
inherited
createElement() → StatelessElement
Inflates this widget into a new element for the tree.
inherited
debugFillProperties(DiagnosticPropertiesBuilder properties) → void
Adds what describes this widget in its element's description (Element.describe) to properties, those not worth showing (a default) left out; an override calls this first. A render object widget adds only what its render object does not show. Only Element.describe calls it: a frame never does.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited

Operators

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