FetchBuilder<T, R> class
Widget that fetch data asynchronously, and display it when available. Handle all possible states: loading, loaded, errors.
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- FetchBuilder
Constructors
-
FetchBuilder.parameterized({Key? key, FetcherConfig? config, FetchBuilderControllerBase<
T, R?> ? controller, required ParameterizedAsyncTask<T, R> task, bool fetchAtInit = true, WidgetBuilder? initBuilder, DataWidgetBuilder<R> ? builder, AsyncValueSetter<R> ? onSuccess, ValueGetter<R?> ? getFromCache, ValueChanged<R> ? saveToCache}) -
A FetchBuilder where FetchBuilderControllerBase.refresh takes a parameter that will be passed to task.
const
Properties
-
builder
→ DataWidgetBuilder<
R> ? -
Child to display when data is available
final
- config → FetcherConfig?
-
Widget configuration, that will override the one provided by DefaultFetcherConfig
final
-
controller
→ FetchBuilderControllerBase<
T, R?> ? -
A controller used to manually refresh data.
final
- fetchAtInit → bool
-
Whether to automatically start task when widget is initialised
final
-
getFromCache
→ ValueGetter<
R?> ? -
Optional function to provide data from cache at creation.
If available, data will be displayed instantly, while fetching newer data from task.
If a
ConnectivityException
happens while fetching, cached data will stay displayed.final - hashCode → int
-
The hash code for this object.
no setterinherited
- initBuilder → WidgetBuilder?
-
When fetchAtInit is true, child to display before fetching starts.
final
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
-
onSuccess
→ AsyncValueSetter<
R> ? -
Called when task has completed with success
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
saveToCache
→ ValueChanged<
R> ? -
Called when task is a success, to save new data to cache.
final
-
task
→ ParameterizedAsyncTask<
T, R> -
Task that fetch and return the data, with optional parameter
If task throws, it will be properly handled (message displayed + report error)
final
Methods
-
createElement(
) → StatefulElement -
Creates a StatefulElement to manage this widget's location in the tree.
inherited
-
createState(
) → State< FetchBuilder< T, R> > -
Creates the mutable state for this widget at a given location in the tree.
override
-
debugDescribeChildren(
) → List< DiagnosticsNode> -
Returns a list of
DiagnosticsNode
objects describing this node's children.inherited -
debugFillProperties(
DiagnosticPropertiesBuilder properties) → void -
Add additional properties associated with the node.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toDiagnosticsNode(
{String? name, DiagnosticsTreeStyle? style}) → DiagnosticsNode -
Returns a debug representation of the object that is used by debugging
tools and by DiagnosticsNode.toStringDeep.
inherited
-
toString(
{DiagnosticLevel minLevel = DiagnosticLevel.info}) → String -
A string representation of this object.
inherited
-
toStringDeep(
{String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug}) → String -
Returns a string representation of this node and its descendants.
inherited
-
toStringShallow(
{String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) → String -
Returns a one-line detailed description of the object.
inherited
-
toStringShort(
) → String -
A short, textual description of this widget.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
basic<
R> ({Key? key, FetcherConfig? config, FetchBuilderControllerBase< Never, R?> ? controller, required AsyncValueGetter<R> task, bool fetchAtInit = true, WidgetBuilder? initBuilder, DataWidgetBuilder<R> ? builder, AsyncValueSetter<R> ? onSuccess, ValueGetter<R?> ? getFromCache, ValueChanged<R> ? saveToCache}) → FetchBuilder<Never, R> - Basic FetchBuilder constructor (not parameterized).