A masterclass in Flutter State management — Riverpod

FlutterTech
10 min readJan 24

Table of content

1. Introduction

2. What is a ‘state’?

3. What is ‘State Management’ and why do you need it?

4. Installing Riverpod

5. Riverpod Fundamentals

5.1 What is a provider?

5.2 How to create a provider?

5.3 How to interact with a provider?

5.4 Different types of provider interactions

6. Different types of Providers

7. Book suggestion

8. Other resources

Introduction

Riverpod is a state management library for Flutter that utilizes the concept of providers and consumers to manage and share ‘state’ throughout an application. It's currently one of the fastest-growing and most liked state management solutions that exist for Flutter.

There are many State Management techniques out there, and Riverpod is just one of them. For me personally, Riverpod was the easiest to learn and it is the one I suggest to (Flutter) starters — which by no means implies it is the best fit for every single application. Each of the State Management solutions has its pros and cons. It is all about choosing the right solution for the application you are going to create, but Riverpod is a good place to start!

What is a ‘state’?

Before diving into how to manage states with Riverpod, it is necessary to understand what a state actually is and how it affects your application.

The state of an application is a condition or situation — an instance or a snapshot that shows the condition of your application at a certain point in time.

For example, your application has two variables, _counts and _color, with values 0 and red respectively. Let’s call this state “State A”. Now, if there is a user interaction that requires changing the values of your variables _counts and _color, let’s say to 1 and blue respectively, that would be a different state of your application, “State B”.

FlutterTech

Flutter developer sharing knowledge through informative blog posts . Join me in expanding our knowledge and building beautiful apps together.

Recommended from Medium

Lists