BloomAsyncBuilder<T>.tuple constructor

BloomAsyncBuilder<T>.tuple(
  1. ({Bloom<T> data, Bloom<bool> pending}) tuple, {
  2. Key? key,
  3. required Widget data(
    1. BuildContext context,
    2. T data
    ),
  4. required Widget loading(
    1. BuildContext context
    ),
  5. Widget error(
    1. BuildContext context,
    2. Object error,
    3. StackTrace stackTrace
    )?,
  6. Widget empty(
    1. BuildContext context
    )?,
  7. bool preserveDataOnPending = true,
})

Creates a structured 4-state asynchronous branching widget directly from a named record tuple ({Bloom<T> data, Bloom<bool> pending}).

Ergonomic shorthand accepting the tuple returned by toBloomTuple() or retainedTuple(), forwarding directly to the primary constructor with zero overhead.

  • tuple: Named record holding data (Bloom<T>) and pending (Bloom<bool>).
  • data: Builder callback invoked when valid payload data of type T is present.
  • loading: Builder callback invoked when the node is in uninitialized or loading state.
  • error: Optional builder callback invoked when an error occurs during evaluation.
  • empty: Optional builder callback invoked when data is empty or node is explicitly empty.
  • preserveDataOnPending: Whether to retain prior valid data during background re-evaluation. Defaults to true.
  • key: Optional widget key.

Examples

BloomAsyncBuilder<UserProfile>.tuple(
  fetchUserProfile().toBloomTuple(),
  data: (context, user) => ProfileCard(user: user),
  loading: (context) => const ShimmerPlaceholder(),
);

Implementation

BloomAsyncBuilder.tuple(
  ({Bloom<T> data, Bloom<bool> pending}) tuple, {
  super.key,
  required this.data,
  required this.loading,
  this.error,
  this.empty,
  this.preserveDataOnPending = true,
})  : bloom = tuple.data,
      pending = tuple.pending;