single<A> static method

AsyncBuilder single<A>(
  1. Future<A> snapshot, {
  2. Key? key,
  3. required Widget onData(
    1. BuildContext context,
    2. A data
    ),
  4. Widget builder(
    1. BuildContext context,
    2. Widget child,
    3. A? data
    )?,
  5. ErrorBuilder? onError,
  6. WidgetBuilder? onLoading,
  7. WidgetBuilder? orElse,
})

Implementation

static AsyncBuilder single<A>(
  Future<A> snapshot, {
  Key? key,
  required Widget Function(BuildContext context, A data) onData,
  Widget Function(BuildContext context, Widget child, A? data)? builder,
  ErrorBuilder? onError,
  WidgetBuilder? onLoading,
  WidgetBuilder? orElse,
}) =>
    AsyncBuilder._(
      key: key,
      snapshots: [snapshot],
      onData: (context, data) => onData(context, data[0] as A),
      builder: (context, child, data) => builder != null
          ? builder.call(context, child, data[0] as A?)
          : child,
      onError: onError,
      onLoading: onLoading,
      orElse: orElse,
    );