Managing State in Flutter

Sep 22 2022 · Dart 2.17, Flutter 3.0, Android Studio Chipmunk

Part 1: Understand State Management

01. Introduction

Episode complete

Play next episode

About this episode
Leave a rating/review
See forum comments
Cinema mode Mark complete Download course materials
Next episode: 02. Understand State Management

Notes: 01. Introduction

Before taking this course, you should be comfortable working in Flutter and Dart. If you need help with some of the core concepts, see our learning path: Flutter Learning Path

Transcript: 01. Introduction

Out of all the topics of Flutter development, there is nothing more discussed and dare I say, controversial than the topic of state management. This is a topic that has spawned thousands forums thread, launched dozens of different implementations, and has inspired scores of tutorials to teach various techniques of doing the same thing. That is, have your UI reflect the state of your data.

Hi there, my name is Brian Moakley and in the course, I’m going to walk through the basic techniques of state management in Flutter so you can know what’s available out of the box and what other packages may work for best for you.

It’s easy to run a simple google search on Flutter State Management and you’ll receive a massive info dump of various solutions with some requiring a lot of boiler plate code. You may often run into prescriptions on how you should work with state management such as learn provider and once you feel comfortable with it, level up to using BLoC as if state management solutions are a sequence of progression as opposed to different solutions for very different reasons.

If you are new to Flutter, one of the most frustrating aspects of learning state management is where to begin. In a framework like SwiftUI, you have state management built right into the framework. And believe it or not, Flutter is the same. The key difference is that some of Flutter’s solutions tended to produce a lot of boilerplate. To which, the community responded by creating better solutions. Now if this was a company like Apple, the flutter team might have incorporated the best features into their own framework and then released it with Flutter.

Apple did that with their SpriteKit framework, copying the Cocos2D api. They modeled Combine after the various react frameworks. The flutter was bit different. They didn’t feel the need to create another state management solution, so they put their backing behind a community project called provider.

In fact, if you go to Flutter official documentation, Flutter recommends using provider as the way for managing your application state.

Now it would be easy to just focus on provider but provider is built on top of several Flutter technologies such as Inherited Widget and Change Notifier. Learning how these work under the hood will allow you to better understand how state is managed with Provider, but more importantly, you’ll understand the differences between other state management systems. That way, you’ll be working with the framework instead of fighting it.

This course is broken down in two parts. In the first part, you’ll learn about all the various tools included with the Flutter Framework. First, you’ll get an overview of state management. You’ll get an overview of the sample project, then you’ll implement some simple state using dependency injection and setState. After which, you’ll be introduced to Value Notifier and how to use it to pass simple values arounds your app. Then you’ll be introduced the Inherited Widgets. Inherited Widgets are Flutter’s attempt at managing state. First, you’ll get an in depth breakdown of how they work after which you, you’ll put them to work.

And that’s just part one. With part two, you’ll put everything you learned in this part and put it to work with the provider package. You’ll get an overview of provider, then you’ll put the simple provider to use. Then you’ll use a change provider. After which, you’ll meet some of the new context methods. Then you’ll learn about consumers and multi providers. Finally, you’ll get an overview of other Provider features. So as you can see, there’s a lot we have to cover in this course. Okay, there’s a lot to cover, so let’s get started by first understanding the problem of state and then learning how Flutter works to solve it.