Managing state in Flutter with Provider (Version 3)

  Рет қаралды 21,576

The Flutter Factory

The Flutter Factory

Күн бұрын

Пікірлер: 65
@TheFlutterFactory
@TheFlutterFactory 5 жыл бұрын
I'll be doing more Flutter videos on state in the future, including Bloc. Are there any issues you had with this video? I'm always looking for ways to improve so leave a comment with any criticisms.
@aytunch
@aytunch 4 жыл бұрын
I am waiting for the BLOC tutorials impatiently:D They are at version 2 already and it is very stable. I think it is time to do a tutorial on it since it's api has changed dramatically and all the bloc videos out there are nearly obsolete. (I am talking about Felix's flutter_bloc package)
@TheFlutterFactory
@TheFlutterFactory 4 жыл бұрын
kzbin.info/www/bejne/rHLCk3WubpeCfpI
@innovationsapps5601
@innovationsapps5601 4 жыл бұрын
It would be great to see a video about GetX, everyone just talks about it now
@tusharchander8935
@tusharchander8935 5 жыл бұрын
The best video on provider for sure! Thanks!
@TheFlutterFactory
@TheFlutterFactory 5 жыл бұрын
Thanks :) I'm excited to do more flutter videos in the future
@tarkkoprulu7751
@tarkkoprulu7751 4 жыл бұрын
Thank you for your up-to-date provider explanation! This was very helpful and easy to understand.
@TheFlutterFactory
@TheFlutterFactory 4 жыл бұрын
Thanks 🙂
@TirthPatel
@TirthPatel 4 жыл бұрын
I've recently started using provider package. This video is very helpful for me. Thanks a lot ❤️
@SunFoxx_
@SunFoxx_ 4 жыл бұрын
Thank you a lot, the clearest explanaition, and you are also covered handling of multiple providers. Very helpful
@purushottampk4530
@purushottampk4530 4 жыл бұрын
This video is good. Helped me a lot. Love from india
@rahulrvp
@rahulrvp 3 жыл бұрын
This is super helpful. Thanks for the effort!
@AamirKhan-zy5yt
@AamirKhan-zy5yt 4 жыл бұрын
Best explanation. Finally understood the package, Thank You! ❤️
@chrisogonas
@chrisogonas 4 жыл бұрын
That was concise, clear and very helpful. Thanks
@gpiccin
@gpiccin 4 жыл бұрын
Really good and simple explanation.
@senayb3
@senayb3 4 жыл бұрын
wow thanks man this really is starting to make sense
@shafiulazam3045
@shafiulazam3045 3 жыл бұрын
thanks, bro. awesome.
@monkeygames4467
@monkeygames4467 4 жыл бұрын
Thanks this video is so helpful, keep throwing info
@blockchainacademy.community
@blockchainacademy.community 4 жыл бұрын
If you've read the Provider docs and provider counter-example from flutter on Github and you still in some doubt. I highly recommend this video (Y)
@GK-pu6yp
@GK-pu6yp 4 жыл бұрын
Great examples... "but wait people, there is more!"
@webghost2009
@webghost2009 4 жыл бұрын
great, keep doing the best stuff.
@cvgaviao
@cvgaviao 4 жыл бұрын
Hi, thank for the video. One question. do we really need a StatefulWidget around the form? wouldn't a Stateless + ChangeNotifierProvider be enough to track the state of a form ?
@TheFlutterFactory
@TheFlutterFactory 4 жыл бұрын
The _currentName and _currentColor are only used in this Widget. Therefore, a Stateful Widget is needed. Don't store state outside of a widget if it isn't used in more than one place. You can always refactor later if you need to access those values in more places.
@dartcode2309
@dartcode2309 4 жыл бұрын
7:17 setState() is unnecessary. ChangeNotifierProvider will listen for changes in the model object and it will rebuild widget.
@azharuddinkhan1865
@azharuddinkhan1865 4 жыл бұрын
Right I wanted to say same thing.
@maheshjamdade1
@maheshjamdade1 4 жыл бұрын
agree and if we don't remove setState using provider doesnt make any sense
@TheFlutterFactory
@TheFlutterFactory 3 жыл бұрын
Good catch. It was part of the original code and I forgot to remove it. It just causes and additional rebuild. I'm currently working on an update to this video for version 4
@abdallahhussein5997
@abdallahhussein5997 2 жыл бұрын
I wish this video can be part two, part 1 could be UI I would like to follow up from scratch
@ibnukhaldun8625
@ibnukhaldun8625 4 жыл бұрын
thanks this video really help me so much as beginner, compared to bloc, which is better? can we use both in same project?
@TheFlutterFactory
@TheFlutterFactory 4 жыл бұрын
Neither is better. It depends on your use case? Provider is a dependency injection library that can be used for state management. Bloc is a state management library. Bloc is better suited towards bigger, enterprise level apps.
@LUKAS3675
@LUKAS3675 5 жыл бұрын
wow how did I missed the selector feature, thank m8!
@TheFlutterFactory
@TheFlutterFactory 5 жыл бұрын
I know. It's great, right? It was only introduced a few weeks ago so most devs haven't tried it out yet. I'll be doing more videos on state management solutions in the future.
@ilkinhamid1072
@ilkinhamid1072 4 жыл бұрын
Thank You
@belqisshida5345
@belqisshida5345 5 жыл бұрын
Widget A. Widget B. Widget C. Here when I update a state in Widget A with provider, the Widgets B and C rebuilds too. So how to avoid unnecessary rebuilds in B and C ?
@TheFlutterFactory
@TheFlutterFactory 5 жыл бұрын
That's what consumer and Selector are for. Don't forget the listen flag that I mentioned in the video. That is VERY important if you want access to your provider without listening for changes.
@AlanTuringWannabe
@AlanTuringWannabe 5 жыл бұрын
I enjoyed your video. Please do a follow up using the FutureBuilder. I'm trying to load in a json file to be used later on in the tree but it isn't rebuilding the children after the future completes. Thank you.
@TheFlutterFactory
@TheFlutterFactory 5 жыл бұрын
I'll be doing videos on futures and streams in the near future
@AlanTuringWannabe
@AlanTuringWannabe 5 жыл бұрын
@@TheFlutterFactory I actually got past my issue. I'll be writing up a Medium entry and posting my code on Github eventually. I'll share my solution when I do.
@jd31068
@jd31068 4 жыл бұрын
Thanks for this, I just finished Max's course on Udemy (which is very good) the Selector though isn't part of it yet
@TheFlutterFactory
@TheFlutterFactory 4 жыл бұрын
Yeah he's great. Selector is very new so I'm not surprised
@GuilhermeCarvalhoCarneiro
@GuilhermeCarvalhoCarneiro 4 жыл бұрын
Hello, first of all congratulations on the content, very interesting. I have a question about the use of the Provider, I am Brazilian and here we have a very active community where in most of the videos it is said that the Provider should not be used in medium and large projects because of the limitation of ChangeNotifier, this information comes ? I wonder why Google would recommend this state manager if it has performance limitations. I apologize for the mistakes, as I do not speak English.
@TheFlutterFactory
@TheFlutterFactory 4 жыл бұрын
Because it's a very powerful and useful tool to have in your toolbox. No single tool is useful for all situations 🙂. Bloc is just another good tool. Useful for bigger apps, but overkill for small apps. Many people use both in the same app. Having more than one option is always a good thing
@GuilhermeCarvalhoCarneiro
@GuilhermeCarvalhoCarneiro 4 жыл бұрын
@@TheFlutterFactory I understand, but would it be a mistake to use Provider on large projects, because of its performance or does it actually make no sense?
@TheFlutterFactory
@TheFlutterFactory 4 жыл бұрын
Provider is ultimately just a dependency injection solution that can also be used for injecting state. Knowing when it makes sense to use either (or a combination of the two) will come with experience. It's all situational
@luckie6593
@luckie6593 4 жыл бұрын
Is provider + stateless widget a good alternative to using stateful widgets ? Any suggestions ?
@TheFlutterFactory
@TheFlutterFactory 4 жыл бұрын
Depends on your situation. There is no one size fits all when comes to software development. If you know for sure you will only have state relevant to one widget (a form might be an example) , maybe you'll just want to put your state locally into a stateful widget.
@luckie6593
@luckie6593 4 жыл бұрын
@@TheFlutterFactory I was thinking the same. Whenever I need a widget with state that is not shared , I will use stateful Widget. Widgets with shared states or data can be stateless with provider
@Inf0rmatix
@Inf0rmatix 4 жыл бұрын
Very good video, thank you so much! Maybe you could cover how you would use Provider with Firebase Collections and Documents? :) Currently working on an app and thinking about the best way to implement some reactive changes to and from firebase. Open to collaboration if you want to, too.
@TheFlutterFactory
@TheFlutterFactory 4 жыл бұрын
I just uploaded a video showing how to retrieve data in Flutter. I'm using a ChangeNotifier to store the data from Firestore. There are other ways to do this such as using StreamBuilders, but I will cover real time changes in future videos. kzbin.info/www/bejne/bWSTlol6qrNosMU
@gaddesathish
@gaddesathish 4 жыл бұрын
What is the best practice to define ChangeNotifierProvider its app level OR page level?
@TheFlutterFactory
@TheFlutterFactory 4 жыл бұрын
What do you mean by 'page level'? The point of using Provider in this video is to provide a reliable source of state across multiple widgets in your app.
@gaddesathish
@gaddesathish 4 жыл бұрын
@@TheFlutterFactory Page level means => Single Screen level. I am a little bit confused we need to define providers in screen level or need to define all providers in an app level using MultiProvider and access them in the screen/widget.
@TheFlutterFactory
@TheFlutterFactory 4 жыл бұрын
@@gaddesathish Define the providers at the root of your app so they're available to any widgets that need access to them. The official docs provide some great visualizations of the tree structure involved flutter.dev/docs/development/data-and-backend/state-mgmt/simple
@gaddesathish
@gaddesathish 4 жыл бұрын
@@TheFlutterFactory Thank you. I got this sentence "You don’t want to place ChangeNotifierProvider higher than necessary (because you don’t want to pollute the scope). But in our case, the only widget that is on top of both MyCart and MyCatalog is MyApp."
@HP-th3nm
@HP-th3nm 3 жыл бұрын
@@gaddesathish Have you found the answer ? If we define providers in screen level, how we define it? Wrap the 'build' method or wrap when we init that screen ?
@georgioss1534
@georgioss1534 4 жыл бұрын
Is this an alternative to Bloc? If so why should I use one over the other?
@TheFlutterFactory
@TheFlutterFactory 4 жыл бұрын
Yes. It's a different state management solution. There's also redux, mobx, etc. You should definitely try both. Bloc is purely state management and scales really well. Provider is a lightweight dependency injection solution that also handles state pretty well. It's great for small and medium sized apps. I generally prefer Provider, but you can actually use both in the same app. There's plenty of articles online that do more deep comparisons
@TheFlutterFactory
@TheFlutterFactory 4 жыл бұрын
flutter.dev/docs/development/data-and-backend/state-mgmt/options
@georgioss1534
@georgioss1534 4 жыл бұрын
@@TheFlutterFactory This is great. Thank you!
@oluwatobilobaOyelowo
@oluwatobilobaOyelowo 4 жыл бұрын
Link to part 2 of the video...
@TheFlutterFactory
@TheFlutterFactory 4 жыл бұрын
There is no part two yet. You can see all the videos on the video tab of the channel
@insane2539
@insane2539 4 жыл бұрын
@@TheFlutterFactory Please make part 2 on future provider, proxy providers and how to make api calls using providers.
How to Manage State in Flutter using BLoC for Beginners
33:20
The Flutter Factory
Рет қаралды 35 М.
Flutter State Management with Provider 5
43:08
The Flutter Factory
Рет қаралды 25 М.
女孩妒忌小丑女? #小丑#shorts
00:34
好人小丑
Рет қаралды 100 МЛН
Electric Flying Bird with Hanging Wire Automatic for Ceiling Parrot
00:15
АЗАРТНИК 4 |СЕЗОН 1 Серия
40:47
Inter Production
Рет қаралды 1,2 МЛН
Flutter Provider: The Essential Guide
17:12
Andrea Bizzotto
Рет қаралды 69 М.
Flutter Provider Package In Depth - Change Notifier Provider
49:53
Pragmatic State Management in Flutter (Google I/O'19)
33:25
Flutter
Рет қаралды 450 М.
Moving from setState to Riverpod in Flutter Part 1
36:00
The Flutter Factory
Рет қаралды 18 М.
Flutter: State Management with Provider
12:38
Paul Halliday
Рет қаралды 78 М.
Flutter Provider - Advanced Firebase Data Management
11:08
Fireship
Рет қаралды 144 М.
I've been using Redis wrong this whole time...
20:53
Dreams of Code
Рет қаралды 356 М.
Flutter State Management - The Grand Tour
14:07
Fireship
Рет қаралды 241 М.
How to Communicate with REST APIs in Flutter
1:06:12
The Flutter Factory
Рет қаралды 16 М.
女孩妒忌小丑女? #小丑#shorts
00:34
好人小丑
Рет қаралды 100 МЛН