Flutter Redux - Single Source of Truth - State Management
Vložit
- čas přidán 27. 07. 2024
- Redux State management is one of the older state management solutions in Flutter environment, but it still amazing. Brian Egan, the maintainer of the package, does a great job to bring over all the benefits and smarts from the old JS Redux Package into today's Flutter Redux Package. In today's video, we will have an overview with a coding example, and I will demonstrate it in our Drinks Example.
Timetable:
00:00 Introduction
00:33 Redux Introduction
04:02 Find the Branch for Redux State Management
18:00 Additional Tools and Tips around Redux
Helpful Links:
github.com/md-weber/state_tut...
#Redux #StateManagement #Flutter
** New Mentorship Program to boost your Flutter career **
gumroad.com/l/ydgtfV
**BOOKS I RECOMMEND**
geni.us/flutterbook
geni.us/clean-code
** CZcams OPTIMIZATION PLUG-INS I USE **
TUBEBUDDY: www.tubebuddy.com/flutterexpl...
VIDIQ: vidiq.com?afmc=7jl
**ALL THE CZcams EQUIPMENT I USE**:
Our current CZcams gear
💻 MacBook Pro: geni.us/mac-book
📹 Lumix FZ1000: geni.us/fz-1000
🎙 Samson Mic: geni.us/samson-mic
🎉 ACCESSORIES:
Satechi USB-C Adapter: geni.us/P9R0
SD Card for 4k Videos: geni.us/PTAc
Disclaimer Flutter Explained (Max & Mahtab) are a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to www.amazon.com.
** Social Medias **
Website: flutter-explained.dev
Say hi to Max
Twitter: / flutter_exp
GitHub Max: github.com/md-weber
LinkedIn: / max-weber-9889a3ba
Say hi to Mahtab
Twitter Mahtab: / mahtab_dev
GitHub Mahtab: github.com/mt-tadayon
Thanks, you made it really easy to understand the concept .
This is nice, i did not know we could use redux with flutter. This is great
awesome video!
VERY NICE!
Good video, I would recommend showing how the app works first so that viewers know what is being discussed in code
Great suggestions thank you!
Sir, if I have more actions do I have to write more reducer functions to update state.. And how to do.. That.. Can you please explain
Thanks for the very clear explanation. Even for a newbie with less than 1y experience. The only question I have about the complete state management topic. How to choose the best state management solution for a project? What are the arguments to make such a decition.
Excellent question, actually the idea of my state management series is that everyone sees slowly that they are actually pretty similar at the end. Hence, there is no absolute need to decide on the best one.
Some are better for a specific use case some are better in other use cases. Important is to stick with one and also understand the differences.
which is best State Management solution for flutter which can be used in large Project.
amaazzzzzzinggggg...
Great tutorial thank you. The only thing I dislike about redux is the name "reducer" is not very intuitive. I think the word "manager" or "worker" is more appropriate. Look forward to hearing others thoughts.
if someone is getting the following error when intializing the state in main.dart The argument type 'AppState' can't be assigned to the parameter type 'AppState Function(AppState, dynamic)'. JUST REMOVE () FROM updateDrinksReducer funtction
How to update specific variable of ViewModel in Redux State Management?
Like Selector Widget in Provider State Management and BlocSelector Widget in Bloc State Management to update specific variable of ViewModel.
Why do you check the action type instead of using polymorphism?
I just wanted to make sure that my IDE understands which type it is.
I was curious why you mutated the value for selectedDrink outside of the reducer.
I enjoyed watching but I believe that violates a principle of redux where we want to isolate values that change in one central location; ie the store and more specifically, within the set of the store’s reducers.
Thanks for clarifying if you can 🎩
Hi Michael, first of all, thanks for your feedback. That is actually a very valid question. To give you the best possible answer, I searched a bit around foremost inside of the invoice ninja repository:
github.com/invoiceninja/admin-portal/blob/master/lib/redux/
They have a lot of examples for reducers. From my personal understanding, which could be wrong, I do not want to have computations inside my reducers, just bare there is a new value and store it please inside the Store.
A reducer is the only place where I can mutate the store to mutate the values I am allowed to do that before. A basic example is a side effect like a network request. But, according to the principles, I am not allowed to do them inside a reducer, so I need to get the values first and pass them in the reducers.
I hope that helps :) and if you have more questions, feel free to contact me anytime.
@Flutter Explained it’s very interesting here because I think we agree on the rules, guidelines rather, this architecture recommends; but I think we’re off with what should be doing what. Could be an interesting conversation for a podcast of mine I’m starting about resolving misunderstandings amongst respectful adult software engineers in good faith. Let me know if you’d be interested in checking it out. Im still in the phase of building up a catalog, but I’d love to get a pilot episode with such a great explainer.
@@someonlinevideos Sure feel free to contact me via my mail or in discord :)
@@FlutterExplained short synchronous mutations like in your case are ok to be put in reducer. If you really want to follow the convention then this mutation should be put inside Middleware. By putting mutation inside onPressed you are doing state management outside Redux which defeats its purpose.
im new in redux, i think its more complex than provider
where is code?
uauu probably i lost some video where you explain in more details Redux for flutter :(............. this i need to understand all better
Sorry, this is just a beginning, not a really deep dive of Flutter Redux. I will add a deep dive into my open topic lists. What would you like to hear in such a video?
@@FlutterExplainedfor example how to use Middleware... if I have something in state more complex than a bool type....
and how to think with redux... when I see you I feel very little little and I think.... ok, with calm you probably understand all this thinks :)
Redux wasn't created by Facebook.
Redux is older than Facebook itself.
Hi there, really I did not know that. According to my research Facebook was founded 2004 and Redux (at least the here refered JS Library) was published in 2015. Additionally I think Dan Abramov and Andrew Clark invented it. Maybe it was not Facebook itself who invented the Library but both are decorated Engineers at Facebook. It would be great if you could give me more insights :)
"the state is immutable" but also "only the reducer can change the state" ????
Well yes, the state is and should be immutable the reducer is not really changing the state it is more an update of the current state. So we replace the old object with a totally new object.
That is because of the second principle of Redux: State is read-only
github.com/fluttercommunity/redux.dart/blob/master/doc/why.md#2-state-is-read-only
I hope that made it a bit more clear.
@@FlutterExplained thanks for your answer. I got it already but sometimes a little bit confusing what you mention in the Video
Alright glad to hear that, sorry if it was a bit unconcice I try to improve in the future. Thanks for your feedback!
All I ever learn from these Redux videos that it is a horrible piece of over complicated trash and I would never want to use it. That goes for any of these state management packages. Seems like there are much easier straight forward ways of doing the same thing. I think it's just another band wagon the IT world is jumping on for no reason.
the zooming in and out while you talk is really distracting
Thanks for your feedback, I will talk with my editor and see if we find a better solution for future videos.