A simple way to access state while robust and testable

A simple way to access state while robust and testable

Welcome to Riverpod! .This project can be considered as a rewrite of provider to make improvements that would be otherwise impossible.For learning how to use Riverpod, see its documentation: https://riverpod.dev

Welcome to Riverpod!

This project can be considered as a rewrite of provider to make improvements that would be otherwise impossible.

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

Long story short:

  • Declare your providers as global variables:

    final myNotifierProvider = ChangeNotifierProvider((_) {
      return MyNotifier();
    class MyNotifier extends ChangeNotifier {
      int count;
      // TODO: typical ChangeNotifier logic
  • Use them inside your widgets in a compile-time safe way. No runtime exceptions!

    class Example extends ConsumerWidget {
      Widget build(BuildContext context, ScopedReader watch) {
        final count = watch(myNotifierProvider);
        return Text(count.toString());

See the FAQ if you have questions around what this means for provider.



If provider is a simplification of InheritedWidgets, then Riverpod is a reimplementation of InheritedWidgets from scratch.

It is very similar to provider in principle, but also has major differences as an attempt to fix the common problems that provider face.

Riverpod has multiple goals. First, it inherits the goals of provider:

  • Being able to safely create, observe and dispose states without having to worry about losing the state on widget rebuild.
  • Making our objects visible in Flutter's devtool by default.
  • Testable and composable
  • Improve the readability of InheritedWidgets when we have multiple of them (which would naturally lead to a deeply nested widget tree).
  • Make apps more scalable with a unidirectional data-flow.

From there, Riverpod goes a few steps beyond:

  • Reading objects is now compile-safe. No more runtime exception.
  • It makes the provider pattern more flexible, which allows supporting commonly requested features like:
    • Being able to have multiple providers of the same type.
    • Disposing the state of a provider when it is no longer used.
    • Have computed states
    • Making a provider private.
  • Simplifies complex object graphs. It is easier to depend on asynchronous state.
  • Makes the pattern independent from Flutter

These are achieved by no longer using InheritedWidgets. Instead, Riverpod implements its own mechanism that works in a similar fashion.

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


Contributions are welcomed!

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
  • Update the documentation / add examples
  • Implement new features by making a pull-request


Why another project when provider already exists?

While provider is largely used and well accepted by the community, it is not perfect either.

People regularly file issues or ask questions about some problems they face, such as:

  • Why do I have a ProviderNotFoundException?
  • How can I make that my state automatically disposed of when not used anymore?
  • How to make a provider that depends on other (potentially complex) providers?

These are legitimate problems, and I believe that something can be improved to fix those.

The issue is, these problems are deeply rooted in how provider works, and fixing those problems is likely impossible without drastic changes to the mechanism of provider.

In a way, if provider is a candle then Riverpod is a lightbulb. They have very similar usages, but we cannot create a lightbulb by improving our candle.

Is it safe to use in production?

Yes, but with caution.

Riverpod recently left its experimental status, but it isn't fully stable either. The API may change slightly when more features are added, and some use-cases may not be as simple as they could be.

But overall, you should be able to use Riverpod without trouble.

Will this get merged with provider at some point?

No. At least not until it is proven that the community likes Riverpod and that it doesn't cause more problems than it solves.

While provider and this project have a lot in common, they do have some major differences. Differences big enough that it would be a large breaking change for users of provider to migrate Riverpod.

Considering that, separating both projects initially sounds like a better compromise.

Will provider be deprecated/stop being supported?

Not in the short term, no.

This project is still experimental and unpopular. While it is, in a way, a provider 2.0, its worth has yet to be proven.

Until it is certain that Riverpod is a better way of doing things and that the community likes it, provider will still be maintained.

Download Details:

Author: rrousselGit

Demo: https://riverpod.dev/

Source Code: https://github.com/rrousselGit/river_pod

flutter dart mobile-apps

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

Google's Flutter 1.20 stable announced with new features - Navoki

Google has announced new flutter 1.20 stable with many improvements, and features, enabling flutter for Desktop and Web

Top 25 Flutter Mobile App Templates in 2020

Flutter has been booming worldwide from the past few years. While there are many popular mobile app development technologies out there, Flutter has managed to leave its mark in the mobile application development world. In this article, we’ve curated the best Flutter app templates available on the market as of July 2020.

Flutter App Development Trends 2020

As the new decade dawns upon us, a slew of technologies has been making a lot of noise to grab the developers’ attention. While native app development is going strong, the trade winds are now blowing towards going cross-platform.

How To Succeed In Mobile App Wireframe Design?

This article covers everything about mobile app wireframe design: what to do and what not, tools used in designing a mobile or web app wireframe, and more.

Top 10 Mobile App Development Companies in India

The mobile application scenario has been continually changing over the years. In recent years India has become a center for mobile app development companies. The increase of smartphones has instantly increased the requirements for these apps. Every year new technological trends occur due to contin