hooks_riverpod
3.5.0, released 2 weeks ago by dash-overflow.net
A reactive caching, data-binding, and state management framework with flutter_hooks integration.
What it does
Hooks Riverpod combines Riverpod state management and dependency injection with flutter_hooks. It handles asynchronous data loading, error states, and caching automatically while making your code testable and modular.
AI-written summary of version 3.5.0, based on the package's README and metadata. Report an inaccuracy
Use it when
- You are using flutter_hooks in your application and want to use Riverpod for state management.
- You need robust caching and automated handling of loading and error states for asynchronous operations.
- You want compile-safe dependency injection and testable state.
Skip it when
- You prefer the standard Flutter InheritedWidget or Provider without additional state libraries.
- You do not use flutter_hooks in your project (use flutter_riverpod instead).
Strengths
- Native integration with flutter_hooks.
- Builds on Riverpod's powerful caching, auto-dispose, and async state handling.
- Compile-safe provider definitions and easy testability.
Weaknesses
- Tied to the flutter_hooks library ecosystem.
- Steeper learning curve compared to simple ValueNotifiers or standard setState.
Setup
- Kind
- Flutter widgets
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 7
Not documented
class Home extends ConsumerWidget {
@override
Widget build(BuildContext context, WidgetRef ref) {
final breweryName = ref.watch(breweryNameProvider);
return switch (breweryName) {
AsyncData(:final value) => Text('data: $value'),
AsyncError(:final error) => Text('error: $error'),
_ => const Text('loading'),
};
}
}Alternatives
Packages that do the same job and could replace hooks_riverpod.
- provider
If you prefer the classic InheritedWidget-based Provider library.
81Compare - flutter_bloc
If you prefer a strict BLoC and event-driven state management pattern.
86Compare
Works with
Packages commonly used together with hooks_riverpod: ones it builds on, ones built on it, and its own family.
- riverpodhooks_riverpod depends on itA reactive caching and data-binding framework. Riverpod makes working with asynchronous code a breeze.
- flutter_riverpodhooks_riverpod depends on itA reactive caching and data-binding framework for Flutter.
- state_notifierhooks_riverpod depends on itValueNotifier outside Flutter for managing state in an immutable manner.
- material_uihooks_riverpod depends on itOfficial Flutter Material UI library implementing Google’s Material Design system.
- flutter_hookshooks_riverpod depends on itA Flutter implementation of React hooks for managing widget life-cycle and code reuse.
- riverpod_annotationSame familyAnnotations for riverpod_generator to enable code generation
- cell_calendarBuilt on hooks_riverpodA customizable Flutter calendar widget inspired by Google Calendar.