Flutter install Riverpod How to Tutorial
In this simple and brief tutorial we are going to see how to install this fantastic package when using Flutter.
So.. How to install Riverpod?
The easiest way to install this package is by simply running "flutter pub add flutter_riverpod" in your terminal; The package will be added automatically in your pubspec.yaml
Since I don't want to give you the fish but I want to learn to you how to fish, that's why I am going to explain about the entire process!
First before installing the package you can retrieve it on pub.dev named "riverpod_flutter"; Pay attention and don't confuse it with "riverpod" only, cause this last one is meant to work with only Dart.
This is the page: Pub.dev Riverpod Flutter
Now you can go under the install tab and copy the line to add it manually, it something like this:
I showed you the entire process cause, most probably the version will be changed when you are going to see this tutorial. So you shoundn't copy my line but I suggest you to check the last version from the website.
After copying this line you should head on to the "pubspec.yaml" and paste it under dependencies
dependencies: flutter: sdk: flutter flutter_riverpod: ^1.0.0 <--- You can copy it HERE!
In this case will be put under dependencies because we need it in production too!
There are some packages that should be put under dev_dependecies cause are needed only under development, like debugging helpers, loggers etc.
Now if you are using Visual Studio Code, by Saving, a command should start automatically and update your packages, if not or you want to do it manually you can type this command on your command line, also known as Terminal or Shell.
flutter pub get
Now the package has been installed and the only thing that you need to do to use it is to import it on the files that is needed.
If you prefer the video version here it is