Search packages, repositories and app categories

Package detailsv3.5.0

hooks_riverpod

A reactive caching and data-binding framework. Riverpod makes working with asynchronous code a breeze.

AndroidiOSmacOSWindowsLinux
30-day downloads
665K
Likes
932
Pub points
150

Install package

flutter pub add hooks_riverpod

Package Overview

Package selection guidance compiled from public package information, community data, and project usage.

Hooks Riverpod is a reactive state management and dependency injection framework for Flutter that simplifies handling asynchronous operations and data binding. Built on top of the Riverpod ecosystem, it integrates seamlessly with Flutter's hooks system, enabling developers to manage state efficiently using functional widgets. It provides automatic reactivity, caching, and clean separation of concerns, making complex state logic more maintainable and testable.

Use cases

  • Managing app-wide state
  • Handling asynchronous data loading
  • Reactive UI updates
  • Dependency injection in large apps
  • Testing stateful logic

Key features

  • Reactive state updates
  • Built-in caching
  • Support for async operations
  • Integration with Flutter hooks
  • Fine-grained dependency control

Suitable for

  • Large-scale Flutter applications
  • Teams prioritizing testability
  • Developers using functional widget patterns
  • Apps with complex state interactions
  • Projects requiring dependency injection

Considerations

  • Steeper learning curve for beginners
  • Requires understanding of Dart's async/await
  • May introduce overhead in simple apps
  • Limited documentation compared to alternatives
  • Needs careful structuring to avoid performance issues

Original README

Original README snapshot from the linked source repository. Visit the repository for the latest content.

Build Status codecov Star on Github License: MIT Discord

Deploys by Netlify

Riverpod


A reactive caching and data-binding framework. https://riverpod.dev Riverpod makes working with asynchronous code a breeze by:

  • Handling errors/loading states by default. No need to manually catch errors
  • Natively supporting advanced scenarios, such as pull-to-refresh
  • Separating the logic from your UI
  • Ensuring your code is testable, scalable and reusable
riverpod pub package
flutter_riverpod pub package
hooks_riverpod pub package

Welcome to Riverpod (anagram of Provider)!

For learning how to use Riverpod, see its documentation: >>> https://riverpod.dev <<<

Long story short:

  • Define network requests by writing a function annotated with @riverpod:

    @riverpod
    Future<String> boredSuggestion(Ref ref) async {
      final response = await http.get(
        Uri.https('boredapi.com', '/api/activity'),
      );
      final json = jsonDecode(response.body);
      return json['activity']! as String;
    }
    
  • Listen to the network request in your UI and gracefully handle loading/error states.

    class Home extends ConsumerWidget {
      @override
      Widget build(BuildContext context, WidgetRef ref) {
        final boredSuggestion = ref.watch(boredSuggestionProvider);
        // Perform a switch-case on the result to handle loading/error states
        return switch (boredSuggestion) {
          AsyncData(:final value) => Text('data: $value'),
          AsyncError(:final error) => Text('error: $error'),
          _ => const Text('loading'),
        };
      }
    }
    

Contributing

Contributions are welcome!

Here is a curated list of how you can help:

  • Report bugs and scenarios that are difficult to implement
  • Report parts of the documentation that are unclear
  • Fix typos/grammar mistakes
  • Update the documentation or add examples
  • Implement new features by making a pull-request

Sponsors

Categories

Dependencies

Dependency list 6 items

Source repository

Projects using this package