riverpod_async_value_widget 1.0.0 copy "riverpod_async_value_widget: ^1.0.0" to clipboard
riverpod_async_value_widget: ^1.0.0 copied to clipboard

Simplify the display of AsyncValues from Riverpod

riverpod_async_value_widget #

GitHub Pub Version Style

Used to simplify the display of AsyncValues from Riverpod.

Usage #

The basic purpose of the package is to save you from having to create error/loading states every time you want to display an AsyncValue. The AsyncValueWidget automatically shows a progress indicator in the loading state, and an error message in the error state.

A "Retry" button can be added by specifying an onRetry callback.

@override
Widget build(BuildContext context, WidgetRef ref) {
    final myValue = ref.watch(myProvider);

    return AsyncValueWidget<String>(
        value: myValue,
        builder: (context, data) {
            return Text(data);
        },
        onRetry: () => ref.refresh(myProvider),
    );
}

Customisation #

There is a variety of customisation options available in AsyncValueWidget. Many of these options can be applied globally (or for any other widget tree scope) using the DefaultAsyncValueWidgetConfig widget:

DefaultAsyncValueWidgetConfig(
    transitionDuration: const Duration(milliseconds: 50),
    // Lots of other options available
    child: MyApp(),
);
0
likes
140
points
55
downloads

Publisher

unverified uploader

Weekly Downloads

Simplify the display of AsyncValues from Riverpod

Repository (GitHub)

Documentation

API reference

License

MIT (license)

Dependencies

flutter, flutter_riverpod

More

Packages that depend on riverpod_async_value_widget