Easiest way to understand BLOC Pattern in Flutter
Vložit
- čas přidán 27. 07. 2024
- Important Note : I have unintentionally switched the stream and sink.
Correct is : Sink is from where we add data to the stream, while source is from where we consume data!
In this video, I have the given fundamental concepts of BLOC pattern (Business Logic Component), furthermore, I have implemented Bloc Pattern in a simple counter application using flutter_bloc and bloc packages.
github.com/themaaz32/bloc_imp... - Věda a technologie
14:27 decreasing by one lol but still very good explanation. Thank you for your time in sharing your knowledge.
He just forgot to change it to minus 1 in CounterBloc. It happens. I do it in my videos sometimes. Then I rewatch and edit in a fix lol.
Hahah! Yeah sorry I forgot! Thank you for understanding!
Thank you Chris!
hahaha that was funny part!
@@EasyApproach That is totally negligible.... when focused on knowledge, such things don't even matter....
9:45 Thanks for that difference between yield and return. Put very simply.
In streams, for putting the value into stream we use yield ;) . Please subscribe the channel.
Excellent explanation of the fundamentals of the BLoC concept and a great example of how to implement the code! Thank you!!
Thank you so much
All the other "Easy" tutorials assume some intermediate level of understanding. this truly is the "EASIEST" bloc tutorial on the internet. thank you so much!
Glad it helped!
Thank you. Please subscribe the channel.
Great video with fantastic way to explain complex things! Thanks for sharing your practical knowledge in this bloc tutorial.
You helped me to learn both Provider and BLOC.
I really appreciate your work.
A lot of thanks to you :)
Thank you. Please subscribe the channel.
Easy approach really has easy approaches
Thank you, gentleman. It Helped.
Relief of working with flutter from one and a half years and finally understanding how bloc works.
Glad it helped!
Great! thank you for simplifying Block...much appreciated
Thank you :)
Thanks Bro! I just got "aha!!" on BLoC after watching this video. Keep up the great work!
Please subscribe the channel if you like the video
Same, I FINALLY got the "aha" moment with BLoC!
awesome! simple way of implementing! thank you
Thanks I appreciate
Thanks for your explanation!
Just one thing, I read the documentation before, I think that importing flutter_bloc is enough, it will import bloc by itself, no need to re-import in the project!
Great stuff.. Thank You for explaining it very well :)
Woah, I finally understood BLoC after nearly giving up on it! Thank you so much for this. It all makes sense now!🎉
Glad it helped!
@@EasyApproach I have a question though - you are using enums while the official docs suggest making classes for every event and also using the equitable package. That's where it gets annoying for me with the excessive boilerplate, so which is the appropriate way to do it?
This is just thee basics. Wait let me share the proper video.
czcams.com/video/yfn1w2Z-Ooo/video.html watch this video. This is second part of Bloc
Muchas gracias mi hermano, buenísima explicación. Thanks for keep it so simple and understandable
Thank you. Please subcribe the channel
Very concise and helpful! thank you
Thank you. Please subscribe the channel.
Really thanks to you for great explanation of bloc
Thanks for this Awesome Video brother. Now i understand bloc clearly.
Thank you brother :) please subscribe the channel for more
@@EasyApproach Already Subscribed brother.
Very clear and concise. Keep it up!
Please subcribe the channel if you like
@@EasyApproach Just did ;) Thanks! Take care out there.
19, 20, 21... "as you can see, it is decrementing by 1"
pardon me :'( :'( ... :D
@@EasyApproach It's cool bro, I understood. Thanks for the vid
I appreciate man. Please subscribe the channel for more videos
Looks like decrementing feature of this BLOC is the most popular in the comments))) I don’t mind as it’s great video explanation
This is a very good explanation. I would like to hear some differences with the Provider package and other Simple alternatives as well. Like BlocProvider is the alternative of Provider, BlocProvider.of(context) is an alternative of Provider.of(context) and BlocBuilder is alternative of StreamBuilder, etc. But very good video man really forced me to subscribe as well.
Excellent thanks brother . Keep it up.
Thank you :)
Nice explanation, thanks !
Thank you. Please subscribe the channel
this is excellent, cheers mate from australia
Thank you. Please subscribe the channel.
EXCELLENT TUTORIAL !!!
Please subcribe the channel if you like
Well done, Mazz :)
Thank you! 😃
Thank you. Its really helped.
Thanks
After watching this, I wished that I could subscribe you n number of times. Great work
Thank you
@@EasyApproach the pleasure is all mine
thanks helps a lot keep doing this you are a very good teacher
Thank you so much please subscribe the channel
actually a good explanation
Saved me. and my day ! thank you man.
Just change in counter_bloc -> yield state-1 (when event is decrement) and u are good to go
Nice video
Haha yeah I did silly mistake. Please subscribe the channel.
Thanks man. Nice explanation
Thank you. Please subscribe the channel.
Best explanation..Thank you so much
Thank you. Please subscribe the channel.
Great job! Thanks.
Thank you. Please subscribe the channel.
This is the easiest video...Thank you
Glad it helped! Please subscribe the channel.
i know Im asking randomly but does someone know a tool to log back into an instagram account??
I was dumb lost my account password. I would love any help you can give me!
@Ares Bowen instablaster ;)
@Timothy Ira Thanks so much for your reply. I found the site thru google and im waiting for the hacking stuff now.
I see it takes a while so I will reply here later when my account password hopefully is recovered.
@Timothy Ira it worked and I actually got access to my account again. I'm so happy!
Thank you so much, you really help me out :D
bro good work!!!
Good Job. Thank you bro !
Thank you. Please subscribe the channel.
Very good! A tip for you for future videos:
1. Always prepare a script of your screencast.
2. Record full video without speaking, just focus on your coding.
3. Voice-over and annotate your video
Thanks for the tips!
I don’t mind if some mistakes occurred if I got everything) nice video!
bro, you thank you so much!
Welcome bro. Please subscribe the channel
I like how the inc/dec events are just enums, not another class!
In CounterBloc you initialize a "initialState" variable to 0, but in the inc/dec event you update a "state" variable. Should these names have been the same?
Is the counterScreen UI widget a child of counterBloc?
In the CounterBloc's mapEventToState, would it have worked if you would have used "return" instead of "yield"? Or, in general must 'async' and 'yield' always go together?
State returns the current value of state of CounteState, so as we are using int as counter state type so you can get the current value of counter by by using state.
Your accent I think is an effort to me well understood. Good English.
In the switch there's an typo. In option to decrement you are adding (+) instead of (-).
Very nicely explained. I was confused AF until now
Thanks Happy to hear!
good stuff..
great job. Thanks for your efforts. subscribed. Accent u know :)
Too many advertisements, However, you explained very well.
can you describe yield state + 1;
how can judge state variable as you are using butt not declare any where in file.
this state variable is from Bloc class to access the current state, you don't have to define it.
very good and simple explanation. thanks sir
Thank you subsrcibe the channel please
@@EasyApproach done
Thank you :)
Nice Video For Beginner Tanx
Thank you so much
kindly please update the bloc tutorial video ,I'm getting errors like this below
"BlocProvider.of() called with a context that doesn't contain a cubit of type CounterBloc"
Amazing! You are awsm!
Thank you so much 😀
Subscribed.
also why we used patterns anyone like provider or bloc etc etc what the actually need of this paradigm in development
because
Sorry to ask but how did you understand BLOC pattern when you were a beginner? Any resources, books that you recommend.Your video has helped a lot but still I want to go deep and learn more
bloclibrary.dev/#/coreconcepts
thank you very much
You are welcome
Bro, how should we handle dispose in flutter_bloc ?
Thanks for sharing
Thank you. Please subscribe the channel.
@@EasyApproach done
Please give example where I can use multiple bloc
At this time (May 2020) the BlocPrivider doesn't have the build: ... Instead, it has create:
Yeah! However, the concept is still same ;)
Whats the difference between BLOC and MVC ? Looks same to me.
Was it really decrementing though?
My bad
Ok so, I tried here and it works, but now, flutter_bloc is 2.1.1, and Android studio is telling me that: 'builder' is deprecated and shouldn't be used. Still working, but is telling me this...
if you havent figured it out already, use create: instead of build:
see pub.dev/packages/flutter_bloc for additional resources
You've missed the Repository layer which supposed to be in between Data and Bloc layer
how about with counsume with A Api
Sorry, I didn't get you
What if you had 100 different states to keep track of globally?
We make different Blocs for different screen!
What is the benefits of adding this??
github link is not working
On clicking decrement it is showing incremented value , I think you by mistakenly given yield state + 1 in decrement case instead of yield state - 1 . Am i right sir ?
yes
you explained very nicely but i am facing a little confusion why we need to used bloc pattern instead of simple variable logic
It is complex but more organized than simple state management as all the related state exist at one place.
@@EasyApproach thanks
Welcome. Please subscribe the channel
@@EasyApproach sure
why we need bloc pattern sir if we can do the same work easily
to have more control on state management!
Provider and Inherited widget are not completely state management, they are more state sharing mechanism but using bloc you would more control and organised code!
@@EasyApproach Thanks
Nice an explained tutorial,,, thank you...
But it's not decrementing the value...
the code that I put on github?
can i request video Flutter_bloc with Listview Builder that receive data from API?
Thank you
Are you a magician :o
That's exactly my next topic!
Will upload the video tomorrow or on Sunday.
Thanks
Thanks
@@EasyApproach WOAHH GREAT!! sure will watch your video asap. when will you upload it btw?
@@kartzhai saturday afternoon or sunday morning!
@@kartzhai you better press the bell icon you will get the notification.
Very good video.
just one thought as viewer, your english is very fluent, just sometimes it tough to get when you speed it up, hope you make it more sound natural.
In latest videos this is improved. Thanks for feedback
Which is best, Bloc pattern or Provider ?
Bloc for big projects as it gives more maintainability and power, however provider is good enough for decent projects!
@@EasyApproach ok thanks
@@EasyApproach Can I use some common state as AppState?
@@KoradiyaAbhay yeah you can if needed!
you didnt show data being passed from the data provider to the bloc............
czcams.com/video/yfn1w2Z-Ooo/video.html try this
thanks bro ,but for this update you should use
class CounterBloc extends Bloc {
CounterBloc(int initialState) : super(initialState) {
on((event, emit) {
switch (event) {
case counterEvent.increment:
emit(state + 1);
break;
case counterEvent.decrement:
emit(state - 1);
break;
}
});
}
}
instead of
class CounterBloc extends Bloc {
CounterBloc(int initialState) : super(initialState);
Stream mapEventToState(counterEvent event) async* {
switch (event) {
case counterEvent.increment:
yield state + 1;
break;
case counterEvent.decrement:
yield state - 1;
break;
}
}
}
It's hilarious that you didn't even notice that decrementing is not working as it should. Great explanation though!
Gracias
Thank you. Please subscribe the channel.
Async does not create another thread. Dart is a single thread language.
I have no problem with your accent. I don't why some people has.
Wrong: Stream is to send data out for consumption and Sink is the point where data is added by the bloc so that it can be directed to stream.
You are correct. Read description
Very cumbersome pattern for simple apps, a lot of work for basic things. But should see in really big apps. Not sure about the performance however.
Hey please make a full video on login and signup using the http get and post request.
Sure
@@EasyApproach i really need to do login and signup using the http get and post. Because i want to create a project so it would be help to me. Your videos are amazing. I will share your videos to frnds.
Thank you. Please subscribe the channel.
I think you are not right telling that async runs in a different thread because all Dart async programming is still synchronous and goes on the same thread. To use different thread you need to create new isolate using features of dart or use compute function which does everything for you. Read some articles about event loop and microTask loop.
I determined to not watch after repeatedly hearing bloc pattren instead of bloc pattern.
Nice video.. He made typo on 10:04.. Rest is very informative.
thankyou please subscribe the channel
I think this is the easiest bloc video that I have ever seen...
Thanks. Please subscribe the channel.
@@EasyApproach already done 😁
Reso coder?
I just go to know him, btw he is great!
=D
Love you bro ❣️ :)
not working
both event yield + 1 as the int state XD
XD you got the bloc right?
@@EasyApproach Yea you explained it pretty well. I used to implement provider package for my state management but now I want to learn using flutter_bloc
@@Vellutia love you bro :*
I think you got the wrong understanding of decreasing the counter :P. BTW great work.
Ahahha pardon meeeeee
@@EasyApproach I have very hard time in understanding the Dependency Injection, have you made any video ? BLOC + Dependency Injection would be nice
CounterBloc.dart
//int get initialState =>0
CounterBloc() : super(0)
main.dart
body:BlocProvider(
//builder:.........
create :...........
)
if this is easy approach than what is complex.........
your initial explanation was is good making things simple but
creating ur porper base is necessary... i think more accurate approach in initial explanation was necessary , every aspects needs to tracked
So.. this seems like a presenter pattern to me...
"State is the data you application is currently showing". Nope. It is ALL the parameters that defines what it should show. It is NOT the data. Data is the last in the queue.
You are right!
ads bhot h
Skip ;)
Good job bro. Just a kind request, please leave your fake accent. Be real!
Thank you for your suggestion :)
Kindly subsrcibe the channel
Lol
bloc pattren
You make your video very nice but your talking speed is very high so keep your speed little bit slow.. thank you
ohhh thanks :D I would take care of it
This dude creates good content but trust me his fake accent kills...
Thank you. Please subscribe the channel.
Ofcourse i did subscribe. Good content is always appreciated ! Could you please create something for CI/CD with codemagic or just paste the link here if you have already done it?
No i didn't will make. Thanks for suggestion :)