Это видео недоступно.
Сожалеем об этом.
#9 - BLoC 6.1.0 Update - Important Changes, context.watch, context.select & context.read
HTML-код
- Опубликовано: 1 дек 2020
- Hi there!
Here's the github repository where you can clone all the source code:
github.com/TheWCKD/blocFromZe...
In this tutorial I will introduce you to the newest changes introduced in the latest version of Flutter BLoC Library - 6.1.0. We'll talk in-depth about the newest concepts like context.watch(), context.select() and context.read() functions.
First of all, context.bloc() and context.repository() got deprecated and will be completely removed in future releases. As a consequence, other functions were added to facilitate the use of bloc library in the future: context.read, context.watch, and context.select.
Context.read is a way to read/access a provided instance of bloc/cubit and won’t rebuild the widget built within the context BuildContext. It should also be used only when and only where you need it to avoid multiple bloc/cubit lookups inside the widget tree.
Context.watch is a way to “subscribe” to a provided bloc/cubit and will rebuild the widget built within the context BuildContext, everytime there is a new state emitted. You can set up multiple context.watch in order to subscribe to multiple blocs/cubits as you would have a MultiBlocBuilder available, so that whenever at least one of the states is updated, the widget built, perhaps with the information needed from these states, will rebuild.
Context.select is also a newly introduced function from where you can easily update a widget based on a simple select condition. It was mainly added for users to have a simpler buildWhen method, when they want to update a widget from the UI as a response to that.
All animations were done in VideoScribe, you can try it by clicking my affiliate link --- www.awin1.com/cread.php?awinm...
You can contact me directly here:
Join my Discord Server --- / discord
Twitter --- / letsgetwckd
Instagram --- / letsgetwckd
Also, if you want to support me furthermore you can become an RUclips Member, donate or buy my courses on Udemy, using the following links:
Become an Official RUclips Member! ---- / flutterly
Buy my Udemy Courses! ---- www.udemy.com/user/tiberiu-po...
Support me on Revolut! ---- revolut.me/letsgetwckd
Buy me a Ko-fi! --- ko-fi.com/wckdyt
Donate me on Paypal! --- www.paypal.me/letsgetwckd
Support me on Patreon! --- / wckdyt
Hello, everyone!
The entire course is now live on Udemy too, get it while it's hot --> www.udemy.com/course/bloc-from-zero-to-hero/?referralCode=E689592633984B34DBEF
Also I have just managed to finally finish the entire BLoC - From Zero to Hero Complete Course, based on this tutorial series. You can check it out here -> ruclips.net/video/THCkkQ-V1-8/видео.html
Hi, what is your next topic?)
I switched from Provider to Bloc thanks to your videos. Best decision I've ever made!
It's funny I made the same decision about 1 year and a half back haha 😂
there is no comparision between the two.Provider can be best understood as a dependency injection tool while bloc is a tool for state management. Bloc also uses provider internally.
Yes, Provided is a dependency injection tool, while BLoC is a state management library, which has also the dependency injection feature of Provider "under the hood" !
Would love it if you updated this course to Bloc 8 !!
The guy I were waiting for 😂
Thanks bro 😊
😂 😂 Appreciate it, brother!
Keep helping us improve our bloc skills
You are the best 👏
Great as usual. From the lasts two videos you've shown a bad uses of bloc, i.e. , programming misconceptions. That's great as we also learn a lot seeing of what not to do. Thanks man.
Thanks, man, indeed, the following videos will again, be mostly about mistakes to be avoided
I updated before but I like to watch those wonderful lectures of u. Thank you very much and keep teaching us these wonderful concepts.
Sorry for taking so long to post, I know you requested the video way back before, but had some others projects to work on. Thanks for the feedback!
@@Flutterly No problem thanks for your time and the wonderful info.
thanks for making it easier to understand the diff between watch and select
You are welcome, mate!
Thank you for making videos about Bloc, its very helpful and easy to understand
Thank you so much!
Your videos are super easy to understand.
One of the best flutter channel on RUclips! Thanks for your hard work man
Really appreciate it, man, thanks! 🌟
best explanation i have got seen till now, waiting for next video you are really helpful
Thanks a ton! I appreciate it!
Thank you for your efforts 👍 with picture I understood more effective
I'm glad to hear that! Thanks!
Awesome video! Thanks for these good explanations.
Thank you so much! ✨
thanks, your tutorials are great!
Great videos thanks for the explanations. keep up the good work 💪
Thank you a ton! I'll keep them coming!
Thanks for sharing!
Best bloc tutorial!
It is going nice with your videos)
thank you bro, I love your lessons
Thank you, brother!
I highly recommend this guy. Just a little focus and magic happends 🔥🔥🔥
Haha, thanks a lot!
Very substantive video. I really like that you are explaining meta issues that cause things to work *that* and not different way. But I have one personal opinion that I like to share. There are too many colorful graphics, icons, arrows etc in your materials that instead of increasing readability of content they overhelm it and start to distract you from whats really important. I believe that - specially in tutor videos - less means more and it would really help if there'd be less slow animations, especially that hand drawing things in the future materials. Cheers.
Yup, I started to remove the hand from tutorial number 12. Thanks for your amazing feedback!
Thank you for such a usefull video
What the heck, i always use buildWhen. :) Thank you, I learned new today.
This is the series I'm waiting for. This is very useful.. but for every event like increment or selection, have to create each cubit for it.. or can we group by a single cubit? I don't have a clear idea about it.
Unfortunately, I don't understand your question, mate. Can you be more specific?
In your example, a increment and decrement events state events are done in single cubit. Consider in case, an app contains a lots of state events such as increment, displaying date from API, selecting a data from list (like MCQ ) and depend upon showing contents like various state events in flutter app. For all these events have to create own state and cubit for each one or creating a common state and cubit and so can we handle these state changes within it?
The general rule is that you create a cubit for every model, or every feature of your app. For example, if you have authentication feature, you should have an authentication bloc with all its subsequent events and states, if you have a country model, you should have a country bloc in which you can retrieve, fetch, display, populate the UI with countries, that bloc should also have its subsequent states. Having only one bloc/cubit for your entire app is wrong.
Will you do videos about API with Bloc?
In the next tutorial series I will start making real world apps with bloc, it's going to be a fun one.
@@Flutterly Yes Start em asap , I don't know I eventually landed on Getx package it has so less boilerplate and easy to learn, bloc seems a no go .....i'd be very happy to learn trueness of bloc as we build real world apps
Thanks men!!! 💪😎
You're welcome, man!
Great video again. What do you know about the 7.0.0 dev version? It says its removing dependency on provider. Does that effect how we write the code or is it just behind the scenes?
Bloc 7.0.0 will be mostly built on the new nu safety Dart, which will probably be released next year or so. Don't need to worry about it right now.
How is it that final name still works when used with context.select() ?! I thought final means that the value of the variable cannot be changed once it is initialized.
Or is it now storing a pointer to the location in memory and so now the value can change, but it will point to the same variable in memory ?
Thanks!!
You're welcome, Oguz! Thank you!
Idk if I am right Flutterly, but is it ok to change the (context) to (_) of the Builder Widget right? since it will start the lookup in the HomeScreen's context? I tried testing it, it works, but I am not sure if it is the right approach?
I may seem to be requesting a lot but well explained hydrated bloc (for example can we store token and some objects on it ) and undo/redo functionalities would be nice. thanks bro.
That was exactly what I was about to cover in the next tutorial, haha, we synced our minds pretty well! No problem, bro
@@Flutterly I was wondering if we can use hydrated bloc instead of sharedprefrence for storing token ....to be honest I didnt try it hh.
thanx
sir it would be great if you make a series on
Stack, Transform and Animation Builder Widget
thanks in Advance
We need you here sir???
Thanks bro. I have a problem. in the previous video you used two approaches for bloc to bloc communication (stream subscription and bloc listener). and when we toggle between internet, the value of counter increased or decreased. but how can we do this in your new approach? in this video you use builder widget and after that you use two new cotext.watch method for internet cubit and counter cubit. but the problem of code is when we change internet connection the counter value doesn't change in UI! how can we solve this problem? I think we should use context.read().increment() somewhere between line 118 to 148. but how can we do this? or we have to use previous approach (stream subscription and bloc listener)?
It doesn't change because I erased the BlocListener function in the tutorial when I first started coding. Bloc to bloc communication methods remains the same. Either by subscribing to another bloc, or by using BlocListener.
thanks brooo
You're welcome, brother!
Thanks for the videos. I'm confused though, what's the point of having BOTH BlocProvider.of(context) AND context.read() ? Why two things to do the same thing? IMO BlocProvider.of makes more sense as we use ThemeProvider.of, mediaquery.of, Navigator.of, Scaffold.of etc
in context.select(BlocA blocA)=> bloc.state.user.name
my question is how to access this variable if you have many states in your BlocA and not all states have variable name
You could do context.select((BlocA blocA) { if (blocA.state is StateA) return blocA.state.user.name} if only the stateA has an user and a name variable inside.
so basicly this destroys the necessity of bloclistener? since it's much simpler syntax to do .watch ?
Hey what is going on everyone !!
This is WCKD and today... 😂
If you have time pls teach us fundamentals of widget tree and element tree.
I covered this topic in my tutorial no. 8, mate, regarding BuildContexts
@@Flutterly I just watched that, thank you. I thought I watched all the videos😅😅😅 ok then teach us about isolates and background services if you have time
as always the content is great but the tempo of the lecture is extremely fast - please try to slow a bit