An introduction to Riverpod
Riverpod is an excellent state management solution for Dart and Flutter applications. It was written from the ground up by the developer of Provider, taking everything learned from the Provider package to overcome its shortcomings. Unlike Provider, Riverpod can also be used on Dart-only projects without Flutter.
In this section, we will look at how to install Riverpod and use it in our application. We will also better understand the view models that we wrote about in Chapter 6, Architecting and Organizing, as they already use Riverpod.
Install the latest version of Riverpod from pub.dev (at the time of writing, it’s 1.0.3). Follow these steps to install Riverpod:
- Add the following under the dependencies of your
pubspec.yaml
file:flutter_Riverpod: ^1.0.3
- Then, run the following command:
flutter pub get
This particular package in the Riverpod family is optimized to be used with Flutter and provides some wrapper widgets...