https://github.com/netsells/riverpod_async_value_widget
https://github.com/netsells/riverpod_async_value_widget
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/netsells/riverpod_async_value_widget
- Owner: netsells
- License: mit
- Created: 2022-07-21T14:22:22.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2023-02-09T11:11:39.000Z (about 2 years ago)
- Last Synced: 2025-02-02T18:51:49.398Z (3 months ago)
- Language: Dart
- Size: 7.81 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# riverpod_async_value_widget

[](https://pub.dev/packages/riverpod_async_value_widget)
[](https://pub.dev/packages/netsells_flutter_analysis)Used to simplify the display of `AsyncValue`s from [Riverpod](https://pub.dev/packages/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.
```dart
@override
Widget build(BuildContext context, WidgetRef ref) {
final myValue = ref.watch(myProvider);return AsyncValueWidget(
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:
```dart
DefaultAsyncValueWidgetConfig(
transitionDuration: const Duration(milliseconds: 50),
// Lots of other options available
child: MyApp(),
);
```