Choosing The Right Flutter State Management Pattern: UI and Shared State

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
State management. Every once in a while a new library or framework arises with another state management approach. Almost every application needs to manage data and a state management framework helps to keep it organized and there are vastly different approaches and patterns. To get an overview we'll cover the most common state management patterns in Flutter and when they are recommended to use and it is also recommended to subscribe to my channel so you don't miss out on any new video in this series. Let's see what state management is about because it's not only a data storage. State management is a pattern, a process in which the application data is maintained and it can also manage input and output flows. So retrieving and storing the data is also part of it. In Flutter the state is defined as whatever data you need in order to rebuild your UI at any moment in time. So what kind of different state management approaches are out there? So in general there is a UI state and a shared state. The UI state or ephemeral state is the simplest state because it's only contained in a single view and cannot be shared between components. So at some point you want to share information between components then you need to beef up the state management with a package like provider, blog or riverpod. That doesn't mean you don't want to use the UI state at all. In this series we will cover the different approaches starting off with the UI state and then we take a look at shared approaches like provider and different packages. Let's have a closer look at the UI state. In Stateful Widgets there is an internal state that can be updated using that state. And after calling the set state the UI will be rendered again by running the build method. Just think of the current selected tab or a progress of an animation. Usually there is no need of other widgets to know the information of this state so you don't need an app state or shared state for this. However if you want to keep information between user sessions like user preferences, notifications or just think of a news app having a read or unread state then you might want to use the app state to keep the data between the sessions. Otherwise all the data is lost in the next session when you open up the app again. So this is not black and white of course. There is no holy grail out there. But there are certain cases in which some patterns are better suited for. Sometimes you need to refactor an UI state into an app state or vice versa. But it is up to you if you want to use an UI state at all. As a rule of thumb do whatever is less awkward. This was the first video of this series. Shared approaches like provider and riverpod will follow. Thanks for watching and if you made it so far you may want to leave a comment what you think about state management. See you in the next one.
Info
Channel: Lambda Dev
Views: 3,971
Rating: undefined out of 5
Keywords: which state management framework, flutter state management, choosing the right flutter state management, Riverpod, Rxdart, lambda, flutter state, state management pattern, best state management, flutter shared state, state management framework, ui state, flutter ui state, choosing the right state management pattern, choosing state management, best flutter state management, best state management pattern, best state management pattern in flutter, state management
Id: iZBRr2LK4oQ
Channel Id: undefined
Length: 2min 56sec (176 seconds)
Published: Sun Jul 23 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.