Skip to content
pubscout

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.

Uses material_uiRock solid
$ flutter pub add hooks_riverpod
Source repository

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.

  • flutter_bloc

    If you prefer a strict BLoC and event-driven state management pattern.

Works with

Packages commonly used together with hooks_riverpod: ones it builds on, ones built on it, and its own family.