AsyncBuilder class

Convenience widget for working with Futures

Example:

class ExampleWidget extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return AsyncBuilder.single<String>(
      Future.delayed(const Duration(seconds: 3), () => 'String from the future'),
      onData: (context, data) => Center(child: Text(data)),
    );
  }
}
Inheritance

Properties

builder Widget Function(BuildContext context, Widget child, List data)
Used to wrap the onData, onError on onLoading result with another Widget such as a Scaffold.
final
dataLength int
final
hashCode int
The hash code for this object.
no setterinherited
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
onData Widget Function(BuildContext context, List data)
Display a widget when the data is loaded
final
onError ErrorBuilder?
Display a widget when an error occurred
final
onLoading WidgetBuilder?
Display a widget while data is loading
final
orElse WidgetBuilder?
Convenience override of onLoading and onError behaviour
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
snapshots Future<List>
final

Methods

build(BuildContext context) Widget
Describes the part of the user interface represented by this widget.
override
createElement() StatelessElement
Creates a StatelessElement to manage this widget's location in the tree.
inherited
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, int wrapWidth = 65}) 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

combine2<A, B>(Future<A> snapshot1, Future<B> snapshot2, {required Widget onData(BuildContext context, A data1, B data2), Widget builder(BuildContext context, Widget child, A? data1, B? data2)?, ErrorBuilder? onError, WidgetBuilder? onLoading, WidgetBuilder? orElse}) AsyncBuilder
combine3<A, B, C>(Future<A> snapshot1, Future<B> snapshot2, Future<C> snapshot3, {required Widget onData(BuildContext context, A data1, B data2, C data3), Widget builder(BuildContext context, Widget child, A? data1, B? data2, C? data3)?, ErrorBuilder? onError, WidgetBuilder? onLoading, WidgetBuilder? orElse}) AsyncBuilder
combine4<A, B, C, D>(Future<A> snapshot1, Future<B> snapshot2, Future<C> snapshot3, Future<D> snapshot4, {required Widget onData(BuildContext context, A data1, B data2, C data3, D data4), Widget builder(BuildContext context, Widget child, A? data1, B? data2, C? data3, D? data4)?, ErrorBuilder? onError, WidgetBuilder? onLoading, WidgetBuilder? orElse}) AsyncBuilder
combine5<A, B, C, D, E>(Future<A> snapshot1, Future<B> snapshot2, Future<C> snapshot3, Future<D> snapshot4, Future<E> snapshot5, {required Widget onData(BuildContext context, A data1, B data2, C data3, D data4, E data5), Widget builder(BuildContext context, Widget child, A? data1, B? data2, C? data3, D? data4, E? data5)?, ErrorBuilder? onError, WidgetBuilder? onLoading, WidgetBuilder? orElse}) AsyncBuilder
combine6<A, B, C, D, E, F>(Future<A> snapshot1, Future<B> snapshot2, Future<C> snapshot3, Future<D> snapshot4, Future<E> snapshot5, Future<F> snapshot6, {required Widget onData(BuildContext context, A data1, B data2, C data3, D data4, E data5, F data6), Widget builder(BuildContext context, Widget child, A? data1, B? data2, C? data3, D? data4, E? data5, F? data6)?, ErrorBuilder? onError, WidgetBuilder? onLoading, WidgetBuilder? orElse}) AsyncBuilder
combine7<A, B, C, D, E, F, G>(Future<A> snapshot1, Future<B> snapshot2, Future<C> snapshot3, Future<D> snapshot4, Future<E> snapshot5, Future<F> snapshot6, Future<G> snapshot7, {required Widget onData(BuildContext context, A data1, B data2, C data3, D data4, E data5, F data6, G data7), Widget builder(BuildContext context, Widget child, A? data1, B? data2, C? data3, D? data4, E? data5, F? data6, G? data7)?, ErrorBuilder? onError, WidgetBuilder? onLoading, WidgetBuilder? orElse}) AsyncBuilder
combine8<A, B, C, D, E, F, G, H>(Future<A> snapshot1, Future<B> snapshot2, Future<C> snapshot3, Future<D> snapshot4, Future<E> snapshot5, Future<F> snapshot6, Future<G> snapshot7, Future<H> snapshot8, {required Widget onData(BuildContext context, A data1, B data2, C data3, D data4, E data5, F data6, G data7, H data8), Widget builder(BuildContext context, Widget child, A? data1, B? data2, C? data3, D? data4, E? data5, F? data6, G? data7, H? data8)?, ErrorBuilder? onError, WidgetBuilder? onLoading, WidgetBuilder? orElse}) AsyncBuilder
combine9<A, B, C, D, E, F, G, H, I>(Future<A> snapshot1, Future<B> snapshot2, Future<C> snapshot3, Future<D> snapshot4, Future<E> snapshot5, Future<F> snapshot6, Future<G> snapshot7, Future<H> snapshot8, Future<I> snapshot9, {required Widget onData(BuildContext context, A data1, B data2, C data3, D data4, E data5, F data6, G data7, H data8, I data9), Widget builder(BuildContext context, Widget child, A? data1, B? data2, C? data3, D? data4, E? data5, F? data6, G? data7, H? data8, I? data9)?, ErrorBuilder? onError, WidgetBuilder? onLoading, WidgetBuilder? orElse}) AsyncBuilder
single<A>(Future<A> snapshot, {Key? key, required Widget onData(BuildContext context, A data), Widget builder(BuildContext context, Widget child, A? data)?, ErrorBuilder? onError, WidgetBuilder? onLoading, WidgetBuilder? orElse}) AsyncBuilder