single<A> static method

AsyncValueBuilder single<A>(
  1. AsyncValue<A> asyncValue, {
  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 AsyncValueBuilder single<A>(
  AsyncValue<A> asyncValue, {
  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,
}) =>
    AsyncValueBuilder._(
      key: key,
      asyncValues: [asyncValue],
      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,
    );