ไม่สามารถเล่นวิดีโอนี้
ขออภัยในความไม่สะดวก
#8 - BuildContext In-Depth Explanation - Fix BlocProvider.of() fails to find a context containing...
ฝัง
- เผยแพร่เมื่อ 16 พ.ย. 2020
- Hi there!
Here's the github repository where you can clone all the source code:
github.com/The...
In this tutorial I will introduce you to how Flutter builds the widget tree and how the widget tree is structured and organised by using build contexts. Build contexts are a really, really, really important feature of Flutter and I can bet most of you don't understand it 100% accurate. So today I will talk about how you can manually build the widget tree by yourself, along with all the widgets and their specific build contexts. I'll also show you how BlocProvider.of(context) works in order to lookup for a BlocProvider widget inside the widget tree. We'll see, understand and fix the well-known BlocProvider.of() fails to find a context containing a specific bloc/cubit error, and many many more!
All animations were done in VideoScribe, you can try it by clicking my affiliate link --- www.awin1.com/...
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 TH-cam Member, donate or buy my courses on Udemy, using the following links:
Become an Official TH-cam Member! ---- / flutterly
Buy my Udemy Courses! ---- www.udemy.com/...
Support me on Revolut! ---- revolut.me/let...
Buy me a Ko-fi! --- ko-fi.com/wckdyt
Donate me on Paypal! --- www.paypal.me/...
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 -> th-cam.com/video/THCkkQ-V1-8/w-d-xo.html
The best explanation about BuildContext I've seen so far! Congratulations!
You're welcome! I am glad I helped!
Watched several BuildContext explanation videos on TH-cam, and most of them were just scratching the surface, and merely advising how devs can work around the gotchas without providing under-the-hood understanding of it.
Thanks, appreciate how detailed you went over this!
Glad I could help, man! ✨ 🥂
This playlist is such a gem..
Even though the code in some videos is a little outdated, the concepts are very well explained, and I always find myself coming back for a revise.
Man, many thanks. You've made my development fun - I can now say I'm familiar with Bloc and I not fighting anymore with my code.
You're welcome, man! I really appreciate that my videos helped you become a better developer!
Same
No way man! I had a really hard time understanding this concept, but this explanation is unique and easy to comprehend. Thank you
Thank you so much! ✨
For a long time. I am working on dart language. And at the same time, I produce products, trainings and content in my own country. I would like to say as a member of the Google Developer Community. Your content helped a lot with the projects I developed. Appreciation of the quality of the contents and the work in the preparation process. Keep going like this.
Thank you so much, I really appreciate your feedback! ✨
It was a the best explanation of BuildContext. Now I have clarity in mind about buildContext.
i just fixed my crashing app just after this 23:18 minutes tutorial on context. Thanks you WCKD, Stay motivated and keep posting such rich content
This is the best explanation of how to build context works with Bloc that I have seen so far. Excellent work done. I hope you receive much more support in future for this.
The tutorial is not only to learn about Bloc concepts but also to learn about BuildContext in Flutter core concepts. Thank you very much :3
I have watched terribly many explanations not only about buildcontext but many other things, I can surely say that this channel is the best one on youtube. Love it, keep it up man
this is priceless, thanks so much. I was having a context nightmare with BloC after migrating from riverpod and was trying to avoid a side project because of it. Youve put me back on track. Great video series, thanks very much.
What a fantastic explanation of BuildContext. Thank you so much for sharing.
This Tutorial series is first where i understood bloc very well Thanks
Best flutter tutorials I’ve ever seen. Thanks for explaining the details in such a clear and concise manner
Thank you so much for this detailed, positive feedback! I really appreciate it!
Wow! Thanks, I finally got a clear explanation of BuildContext. You are great!
I'm really glad! ✨
Best explanation on TH-cam, thank you!
Thanks a lot! I appreciate your feedback!
Hi, I just wanna say that I really appreciate what you're doing here. I've binge watched all your previous videos up to here and have made sure to like all of them atleast as a show of gratitude :D
I really like the way you explain and visualize the concepts that's very easy to understand and follow through. I was actually researching about this topic for a while and stopped since I cannot grasp it properly then. Watching your videos made me confident about it now and in turn made me feel positive and happy.
I was actually really excited when I was talking about your videos to someone and even said that the ability for it to teach is very good and could actually be a worth-it paid course, if ever.
Keep up the great work! You've really improved a lot.
Thank you so much for your kind words, man! I really appreciate the positive feedback you gave me! I'll struggle to give you and my viewers the best tutorials! I'm glad you think I have improved over time! Thanks a lot again and hope I'll see you soon in the comments section of newer vids!
You deserve it! I was actually a little sad that I've seen everything up to this point that I have nothing else until your next one - in a good way that is. It's like a good TV show that you just wanna see the next one as soon as possible. :D
I'm looking forward to them. Keep safe also!
Thank you so much! ✨ I prefer quality over quantity so that's why it's taking so much time to post tutorials
Finally get cleared my all doubts regarding context.thanks a lot sir
All the best!
thanks for this playlist about bloc, it make me easier to learn it, keep it up man.... I will wait for another tutorial playlist from you
Thank you for this great tutorial. I am looking forward to see tutorials for another topics too.
Thank you so much!
Best explanation on BuildContext. Thank you
Love your work! This crucial topic is overlooked by all flutter tutorials I've seen so far.
Wow you are amazing, I was confused why I received this error and now I know why. Thanks a lot.
Thank you, brother 🤍
Thanks, WCKD. Must watch and needed one!!! I personally addict to bloc and your videos as well.
Keep rocking!!!
Nice to hear that, mate! 🌟 Thanks a ton!
This is Actually the best explanation of BuildContext. Thank you so much
Yup, Shared it with on of my mate, who joined recently to work along with me on existing project built with bloc. Hopefully he will learn quickly(hopefully my mate won't take much time as I took to understand bloc in my initial days 😜) and will get fair idea on what's going on.
Thank once again ❤
Looking ahead for more advance videos.
Thank you!
Yours is the first channel I have subscribed in my youtube life. You are gifted! Would you mind sharing which video making tool do you use? I will try it in my office presentations
This video and your way of explaining things are so underrated. You've got my subscription and thanks for doing this work. I learned a lot and it was awesome :)
Thank you so much for your kind feedback, mate! I appreciate every word you said and I couldn't be happier to help you in pursuing the level of understanding bloc!
I agree. He should make a course on how to teach technical subjects.
This video should be added to the Bloc documentation. LIKED and SUBSCRIBED!.
Thank you so much! ✨
The playlist is there in the bloc documentation. :)
Good sir, you make me understand how build context works.. Thank you so much..
One of the best explanation on Build context. Wonderful work
Thank you so much! ✨
easy to understand the best explanation so far
Thank you so much! ✨
Developer need to be aware all time with this context thing. Flutter supposed to be easy 😅. I really enjoyed and learned a lot from the videos. Thank you.
Indeed, that's why I considered it so be a really, really important tutorial! Thanks!
A lot of thanks man, I hope, you will continue create tutorial videos in this context). I'm waiting for another videos about flutter
Thank you, man! Appreciate it!
Omg i have just found a treasure.thank u for the wonderful easy explanation i think i will watch all your videos now❤️❤️❤️❤️
You explain amazingly! Very complete and concise. you deserve million subscriber and I hope continue your work. Thank you sir 🌷
Thank you so much! Hopefully I'll get there someday! I appreciate it! ♥
This level of details in a tutorial, And i wonder how much hardworking you put to make this video. Thank you again.
About 1-2 weeks of work for a tutorial
@@Flutterly That's lots of time , Thanks WCKD for these tutorials, waiting for more of your tutorials in future. Love
You're welcome, mate! I'm really happy you like them!
@@Flutterly thx a lot
Thank you for everything. I was struggling about learning BLoc but I understand most of the logic behind the scenes now. Best explanation :)
This is the best explaination of BuildContext ever far.
Thank you so much! ✨
best explanation of contex and flutter 🔥🔥🔥🔥
Thanks a lot!
This is more informative than all the other explanations. Thanks Flutterly
Thanks, Ben! I appreciate it!
Thank you so much for this video, please continue to make more. I really love the way you explain everything in detail.
Thank you so much, brother! I will!
Hey, WCKD, I Started learning flutter recently, and to be honest, I was having a really tough time understanding how this whole BLoC thing worked till now.
I Love how you illustrate each concept pictorially.
Huge Fan or your teaching.
I would appreciate an example of BLoC with Forms and to be specific, An Entire Login Flow. Thanks.
For sure I'll do that in the future, man, after I finish all these tutorials!
@@Flutterly much appreciated 💞
You're sooo good, thank you so much, I never really understood context before this video
... i was searching that « buildcontext » video since a while :) thanks Wckd !
I'm glad I could help you, bro! You're welcome!
Best teacher great explained by simple and deeper pls make more video with firebase love from India ❤️
It is one of the important topic that you presented to us Thank you man
Thank you so much, man!
Really really GREAT and PERFECT explanation
Thank you from my heart ❤❤❤
Mind blown 🤯🤯. You make everything look easy ❤❤
Man! Keep up the good work! Love your tutorials. Please make more videos like this!
Thank you so much! ✨
This was awesome! Thank you so much. Love this entire series and especially all the hard work it took to painstakingly create the animations.
I appreciate your efforts and time to make such a great video. Thanks WCKD💙💻👓
It's WCKD, mate, thanks! 🌟
This man is absolutely incredible.
Man your videos are awesome... I really hope you do something on RXdart
Will do in the future
Bro, I
Haha, thank you so much, brother! I really appreciate all your kind words! Hope you'll stay here on this channel furthermore, cause more awesome series will come in the future!
OMG that great work and Good animation to understand.
thanks for the tutorials.
Thank you sir. Please make a complete project using BLoC pattern.
I will make a complete series building different apps!
your explanation are amazing 🤩
Thank you so much, mate! 🌟
Thank you for explaining in-depth concept of BuildContext and widget tree, really loved your work!
Could you also please make a tutorial for the element and render tree too?
GOATED Explanation man.
Such a wonderful explanation!!
This tutorial is really helpful ! Thanks a lot ! I like it .
Thanks so much for your tutorials. Quick question though.
Instead of adding Builder(context) on RaisedButton, can adding a context in the BlocProvider be enough to see the context? Such as
BlocProvider(
create: (context)=> BlocA(),
child: RaisedButton…..
Greeeeeeat, It answers all my question, Thank you ❤️️
Thanks, I think your channel is one of the best
Amazing!
One question about the drawing: Why CounterCubit context is child of InternetCubit in the tree? I thought the tree was: MyApp > MultiProvider > MaterialApp ... The 2 cubits are not child because they instanciate a new context as create param, so they are not child of the MyApp context in that drawing (or if we have to include them, we can put them on the same level with MaterialApp).
Maybe i'm lost sorry :\
No, you're not right. As I mentioned inside the tutorial, what MultiBlocProvider(BlocA,BlocB,BloC) does is actually a way of writing BlocA > BlocB > BlocC inside the widget tree. So, in our case, it's MyApp > MultiBlocProvider(InternetCubit,CounterCubit) > MaterialApp, but MultiBlocProvider(InternetCubit,CounterCubit) behind the curtains translates into InternetCubit > CounterCubit, therefore the widget tree is MyApp > MultiBlocProvider (which needs to be written because it is the thing that wraps out next cubits) > InternetCubit > CounterCubit > MaterialApp. You should watch the entire tutorial and you'll understand better why it's this way.
@@Flutterly Thank you for the answer. I will rewatch it again :D
Thanks so much for the magnificent explanation, but I have a question :
In the last 5 minutes of the video when you gave the 3 examples, you put the BlocProvider's context as "_" which means that it will make the context anonymous like you said and that's why the .of's context will start searching from the build's context. But what if we changed the context of BlocPovider from "_ " to "context" for example. Now, the BlocProvider doesn't have an anonymous context anymore and thus the .of's context will start searching from the BlocProvider's context (because it's not anonymous anymore) and therefore, there will be no error as it will find the BlocProvider immediately and thus we don't need to wrap RaisedButton widget with Builder widget anymore !! So, my question here is what I'm saying is right or not ?
Thank you for releasing this video, it was really helpful and educating
You're welcome, man, thank you!
Thank you so much again man! Again! Another awesome tutorial!! :D
My pleasure!
Amazing explanation .....
always amazing content,
respect man for your struggle🙌🙌🙌
Once a legend said, ''The only way is UP"!
Up in the sky 👆 🌟 😂
This is the great explanation 😍🔥
Super useful. Thanks
Thank you!
thanks, bro hope you make videos using API with bloc
Sure thing in the future
Just wondering what's your learning process to understand the internals of flutter. Is it by studying flutters' codebase or by reading book? Hope for your answer and thanks alot 🙂
i personally think the concept of widget tree is kinda similar to that of linked list but the difference is that instead of traversing forward, we can only traverse backward all the way to the root node. does anybody have the same thought?
You are trully wicked sir
Do you have any more content about Flutter?
Some few widgets don't have build method, how do they get their buildcontexts?
Welcome back 🙂
Thks for your videos
Thank you! Sorry for the delays, this video took over 2 weeks to be made!
It's worth it. The content is understandable as always.
Nice video
great explanation, really helpful tutorial. thank you very much, keep going please we're supporting you. :3
Thank you so much for your support, it is greatly appreciated!
It made me even more confused :D I need to watch it again
*not because of the problem of the tutorial
You've made an Absolutely Great Video 👍✨
Again Great video , Thank you so much....
You're welcome, thanks!
very good explanation, thanks
This is some great quality content. You're awesome. Thanks
Great explanation. Keep it up!
when will you post your next video? i am eagerly waiting!
Most probably tomorrow or the day after tomorrow, it takes a ton of time to make them and I also have multiple other projects I'm currently working on so time is my biggest enemy right now, haha 😂
thank you bro for teaching bloc
what a nice tutorial, thank you so much
Great video learnt a lot from your videos
Thanks that was great context 👍. I have a question btw Does closing a cubit on sign out refresh all it's data? Or any way to refresh the cubit data on sign in or sign out?
I don't quite understand your question. Can you give me a more specific scenario?
@@Flutterly I want my cubit to initialize and load data after sign in but it holds the same data of the earlier user. I close my cubit on sign out but still it holds the previous user data.
You must be doing something wrong. Whenever you sign in an user, you should have a state called logged_in with an user model perhaps sent to the state. So whenever you sign in an user, your cubit will emit a loggen in state with the respective user. You need to update your user, rather than the bloc/cubit you're using.
@@Flutterly actually the sign in cubit is different and the cubits which I want to refresh or call new data are different so I tried with bloc listener to listen on state changes on sign in but still will check once more. Thanks for your reply 👍
Maaaaaaaaan! That was Amazing explanation
excellent tutorial thank you very much for teach me this
AWESOME content! Big thanks
can I depends on those videos to start working on Bloc, since my UI is finished?
by the way, you are the best
Excellent tutorial,
Does this build context same context behavior in android?
Oh, My god, you are so great.