gitmyhub

riverpod

Dart ★ 7.3k updated 8d ago

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

Riverpod is a state management framework for Flutter and Dart apps that automatically handles data fetching, caching, loading states, and error handling without manual boilerplate.

DartFluttersetup: moderatecomplexity 3/5

Riverpod is a framework for Flutter and Dart applications that handles how your app stores, fetches, and shares data. Flutter is a toolkit for building mobile and desktop apps using the Dart programming language. When you build an app, you often need to fetch data from the internet, share that data across different screens, and handle cases where the data is still loading or where a network request failed. Riverpod provides a structured way to do all of this without scattering that logic throughout your UI code.

The core idea is that you define your data sources, called providers, as annotated functions. Riverpod then manages when those functions run, caches their results, and automatically notifies any part of your UI that depends on them whenever the data changes. If a network request is loading, Riverpod gives you the loading state. If it fails, you get the error state. You do not need to write manual try-catch blocks or loading flags scattered through your widgets.

Riverpod is an anagram of Provider, which is an older Flutter state management package by the same author. Riverpod was written to address design limitations in that earlier package, particularly around testability and compile-time safety. Unlike the predecessor, Riverpod does not rely on the widget tree for accessing state, which makes it easier to write tests and share state between parts of the app that are not directly related in the UI hierarchy.

The package comes in three variants: a plain Dart version, a Flutter-specific version, and a version that integrates with Flutter Hooks. Full documentation lives at riverpod.dev. The README is brief and points there for anything beyond the basic usage example.

Where it fits