async_value_group is a a Dart library for grouping some riverpod AsyncValues into single AsyncValue.

  • Grouping some AsyncValues into single AsyncValue and retrieve all AsyncValue.data as a tuple.
  • Waiting to be done multiple asynchronous process.
  • If you use hooks_riverpod, call AsyncValue.when only once in Widget.build method even if multiple AsyncValues are required.


import 'package:flutter/material.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:async_value_group/async_value_group.dart';

class TweetsPage extends HookConsumerWidget {
  const TweetsPage({Key? key}) : super(key: key);

  Widget build(BuildContext context, WidgetRef ref) {
    return AsyncValueGroup.group2(
      data: (t) => t.t1.isEmpty ? const TweetsEmpty() : TweetsBody(tweets: t.t1, user: t.t2),
      error: (error, st) => ErrorPage(error: error),
      loading: () => const Loading(),