Watch this episode for free — or access the full course as a raywenderlich.com Professional Subscriber. Learn more here
Managing State in Flutter
Part 1: Understand State Management Introduction
— Flutter & Dart

Lesson Complete

Play Next Lesson
Next

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

Provides an overview of the state management, why it is important to know, and the various topics that are covered in this course.

Contributors

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.

Reviews

Comments