async_value_group 1.0.1 copy "async_value_group: ^1.0.1" to clipboard
async_value_group: ^1.0.1 copied to clipboard

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

Features #

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.

Usage #

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);

  @override
  Widget build(BuildContext context, WidgetRef ref) {
    return AsyncValueGroup.group2(
      ref.watch(tweetsProvider),
      ref.watch(userProvider),
    ).when(
      data: (t) => t.$1.isEmpty ? const TweetsEmpty() : TweetsBody(tweets: t.$1, user: t.$2),
      error: (error, st) => ErrorPage(error: error),
      loading: () => const Loading(),
    );
  }
}
16
likes
150
points
568
downloads

Publisher

verified publisherbannzai.dev

Weekly Downloads

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

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter, riverpod

More

Packages that depend on async_value_group