Skip to content
pubscout

async_value_group

1.0.1, released 3 years ago by bannzai.dev

Group multiple Riverpod AsyncValues into a single AsyncValue

WASM-ready
$ flutter pub add async_value_group
Source repository

What it does

It groups several Riverpod AsyncValues together into a single AsyncValue, allowing you to retrieve all data values as a tuple. This enables calling AsyncValue.when only once when multiple asynchronous providers are needed in a widget.

AI-written summary of version 1.0.1, based on the package's README and metadata. Report an inaccuracy

Use it when

  • You need to consume multiple Riverpod AsyncValues in a single widget and want to avoid nesting multiple .when() calls.
  • You want to wait for multiple asynchronous processes together and handle their states cleanly.

Skip it when

  • You are not using Riverpod for state management.
  • You only need to watch a single AsyncValue.

Strengths

  • Simplifies widget build methods by reducing multiple AsyncValue.when calls down to one.
  • Easily handles grouping of multiple providers into tuples.

Weaknesses

  • Limited to Riverpod AsyncValues.
  • No topics documented in the package metadata.

Setup

Kind
Flutter widgets
Effort
Low
Code generation
No
Direct dependencies
1

not documented

return AsyncValueGroup.group2(
  ref.watch(tweetsProvider),
  ref.watch(userProvider),
).when(
  data: (t) => TweetsBody(tweets: t.$1, user: t.$2),
  error: (error, st) => ErrorPage(error: error),
  loading: () => const Loading(),
);

Alternatives

Packages that do the same job and could replace async_value_group.

  • jaspr_riverpod

    Riverpod‑style state management for Jaspr with BuildContext extensions and server‑client sync.

  • refena

    A state management and dependency injection library inspired by Riverpod and async_redux.

  • refena_flutter

    A state management and dependency injection library for Dart and Flutter.

  • stream_with_value

    Encapsulates a Stream<T> with its latest value and load state.

Works with

Packages commonly used together with async_value_group: ones it builds on, ones built on it, and its own family.