Flutter Bloc Tutorial For Beginners | BLoC Architecture/Pattern & State Management Explained

Поділитися
Вставка
  • Опубліковано 20 лип 2024
  • In this course, we will learn about the Flutter Bloc State Management Tool along with the BLoC Architecture/Pattern by creating 4 Projects using Flutter! We will learn about Bloc, Cubit, BlocProvider, BlocBuilder, BlocConsumer, BlocListener, RepositoryProvider, BlocObserver and various methods and functionalities they offer. Along with that, we'll learn about Bloc vs Cubit, understanding when to use what and just simplifying Bloc down by a lot. We'll also learn about writing clean code by implementing BLoC Pattern in an API Powered Project.
    Source Code: github.com/RivaanRanawat/flut...
    📌 Discord Server - / discord
    Resources:
    20 Hours Flutter Beginners Course - • The Complete Dart & Fl...
    Provider in 7 Minutes - • Flutter Provider State...
    ToDo List Beginner Files - github.com/RivaanRanawat/flut...
    Login Form App Beginner Files - github.com/RivaanRanawat/flut...
    Weather App Beginner Files - github.com/RivaanRanawat/flut...
    Timestamps:
    (00:00:00) Introduction
    (00:00:44) Project Setup + Bloc Installation
    (00:03:39) Counter App With Cubit State Management - Overview
    (00:30:38) Counter App With Bloc State Management - Overview
    (00:49:48) Similarity Between Bloc & Cubit
    (00:50:18) Todo List App With Cubit - BlocBuilder, onChange, onError
    (01:11:59) Login Form App with Bloc - States, Events, BlocListener, BlocConsumer, onTransition, bloc_concurrency
    (01:56:31) BlocObserver
    (02:01:09) Weather App - BLoC Architecture Pattern
    (02:30:18) BLoC Pattern Recap
    (02:33:36) Is BLoC Unnecessary work?
    (02:34:15) Conclusion
    Connect With Me Here:
    GitHub: github.com/rivaanranawat
    Linkedin: / rivaan-ranawat
    X: x.com/RanawatRivaan
    Medium: / namanrivaan
    Instagram: / optimalcoding

КОМЕНТАРІ • 203

  • @GameSteals
    @GameSteals 2 місяці тому +13

    At 1:04:56, no offense, but the explanation seemed a bit flaky. Here are my 2 cents on why the state is not changing even after adding a new to-do object in the 'state' list.
    When we first initiate the state with an empty list [], this list has an address in memory (say A1), similar to how a house has an address.
    Continuing with this analogy, like how if more people start residing in the house, the address of the house does not change, similarly if we add more elements in the list, the address of the list will also not change.
    The emit() function likely compares two states based on the r-value (which is address in the case of Lists, Maps, and objects, and the actual value in the case of primitives like int, float, double, etc).
    Here emit() concludes that the state has not changed, since the address of the list has not changed, therefore it stops any further processing.
    Therefore, to actually change the address of the list,
    1. We have to create a copy of the list (This creates a new list with a new address (say A2))
    2. Add the items in this new list
    3. Pass this new list to emit()
    Now when emit() compares the two lists, it finds that the address is different, and it updates the state. Hope this helped someone.

    • @RivaanRanawat
      @RivaanRanawat  2 місяці тому +7

      Good explanation, thanks for taking the time to write & help others!

    • @sagarshah5341
      @sagarshah5341 Місяць тому +2

      Man you are good at DSA!

    • @jatindersinghaujla
      @jatindersinghaujla 17 днів тому

      ​@@sagarshah5341 it's general programming concepts not dsa. It works based on the address of list, map etc. To understand this in details need to know how equals and hashcode works

    • @sagarshah5341
      @sagarshah5341 17 днів тому

      @@jatindersinghaujla The guy understood what I was implying.

  • @MrxAmjad
    @MrxAmjad 7 місяців тому +71

    As of now, This man is God Gift for flutter developer, His insane contribution for Flutter Developers always be memorable in flutter history, this much quality content absolutely for free is ❤❤❤❤❤.

  • @samuelvmoura
    @samuelvmoura 3 місяці тому +2

    Wow, I've been after some good, well explained bloc tutorials for a while and yours got literally all my questions answered. thank you so much!

  • @hashir2749
    @hashir2749 4 місяці тому +4

    Seen a lot of state management tutorials but this one is on Top.

  • @Mitsue51
    @Mitsue51 4 місяці тому

    Thanks, it's really helpful because following the login tutorial from the bloc documentation wasn't enough for a beginner like me. You explain really well, thanks for your time

  • @LinuxUser_
    @LinuxUser_ 7 місяців тому +4

    As my 7th-semester exams are concluding next week in pursuit of a CS degree, I'm eager to delve into Flutter projects.
    I already have a grasp of Flutter and Dart basics. However, time is limited, and with companies beginning recruitment, I'm feeling the pressure due to the absence of projects.
    I would greatly appreciate your guidance, Rivaan, including video recommendations to kickstart my Flutter journey, project ideas, and tips for both project development and placement preparation.
    Your assistance means a lot 🙏🏻

  • @numan947
    @numan947 3 місяці тому

    Hey! Just wanted to say thanks! I was on the fence about whether to invest about 3 hours of my time in it, but I am glad I did. Your shown examples along with the explanations helped clear out a lot of the confusions and questions I had.

  • @hussainrizvi5423
    @hussainrizvi5423 6 місяців тому

    OH MY GOD!!! THANK YOU SO MUCH SIR... this is by far the best video for bloc tutorial.

  • @rakshithadilshan9888
    @rakshithadilshan9888 5 місяців тому +3

    Very valuable content. No one has taught like this❤

  • @synnotus
    @synnotus 7 місяців тому +4

    You are the best thing ever happened to flutter. Your explanations are beginner friendly. Thanks

  • @kevinvishal9071
    @kevinvishal9071 4 місяці тому

    This tutorial is a gem for Flutter developers. The explanations provided are incredibly detailed, making a complex pattern appear straightforward. I'm grateful for the thorough guidance provided by the instructor. Thank you, Master.❤

  • @its_suresh_v
    @its_suresh_v 6 місяців тому

    Riwan love you man the way you explained bloc outstanding brother, Crystal-clear explanation superb 👏

  • @arminyazdian6598
    @arminyazdian6598 3 місяці тому

    Thank you so much for putting huge amount of time and effort!

  • @malukishtiaq
    @malukishtiaq 4 місяці тому

    You are just awesome my friend. I watch your videos on priority. It helps me stay polished.

  • @richardwindley7355
    @richardwindley7355 6 місяців тому +1

    When I started watching, I thought "I won't sit here for 2.5 hours..." but I did. This is a great video which explains the subject matter very clearly with good examples.

  • @pratyushvaibhav
    @pratyushvaibhav 7 місяців тому +8

    Hats off
    A big round of applause ✋
    A big thanks for this 🙏

  • @chitko1706
    @chitko1706 6 місяців тому

    awesome sir. you are the mentor who i was looking for🎉.please,upload more.

  • @anurudhsingh3397
    @anurudhsingh3397 5 місяців тому +1

    I have no words!! Fluent like air!!!! Thanks !!!!

  • @Badshah1614
    @Badshah1614 7 місяців тому

    Thank you so much sir for uploading a new flutter video again . How long have we been waiting for your next Flutter video?

  • @jatindersinghaujla
    @jatindersinghaujla 17 днів тому

    This video is worth watching. You cleared so many doubts.

  • @hurbangash1302
    @hurbangash1302 3 місяці тому

    i did not know bloc was so easy .thank you so much rivan bhai

  • @nisafv.a8710
    @nisafv.a8710 7 місяців тому +1

    Thankyou so much maaan . Really helpful ❤ . God bless

  • @DataSet
    @DataSet 5 місяців тому +5

    For those who don't know, Rivaan is only 17

    • @c00per_
      @c00per_ 3 місяці тому +1

      Ikrrrr💀🗿💥

  • @amityadav85
    @amityadav85 6 місяців тому

    brilliant! thank you kind sir! very nice method of teaching!

  • @muammar88
    @muammar88 4 місяці тому

    Man you rock! Thanks a lot for sharing your expertise ❤

  • @rolesquare3624
    @rolesquare3624 7 місяців тому

    I was wondering when Rivaan will move to bloc and here it is. Thank you for showing me a lot in flutter.

  • @aizen_3438
    @aizen_3438 7 місяців тому +2

    Hats off waiting for this 🔥

  • @roninspect4357
    @roninspect4357 7 місяців тому +4

    a big project with bloc and supabase would be very awesome & unique.

  • @jayisampelliwar5065
    @jayisampelliwar5065 7 місяців тому

    finally, the Most awaited video ✅ best flutter channel exists on YT

  • @muhammadbilal-sd9kf
    @muhammadbilal-sd9kf 3 місяці тому

    Your way of explaining bloc pattern is amazing.
    Please make a video of about MVVM architecture using provide.
    thanks

  • @pravinprince3221
    @pravinprince3221 7 місяців тому

    Thank you for the wonderful tutorial bro, it is very helpful for me and my team thanks again

  • @livingfreeely
    @livingfreeely 3 місяці тому

    thanks a lot Rivaan

  • @abidhasansnigdho
    @abidhasansnigdho 7 місяців тому

    You are awesome at making complex things easy ❤

  • @manohar.acharya
    @manohar.acharya 7 місяців тому +1

    was despereatly waiting for bloc wanna see fullstack project on bloc & cubit

  • @sujalutekar9417
    @sujalutekar9417 7 місяців тому

    I was waiting for this only 🔥🔥

  • @aash1r869
    @aash1r869 7 місяців тому

    Hey Rivaan, Kindly make a video on Flutter using Stacked state management, tutorials on stacked are almost impossible to find, would be of great helpp!

  • @aouadicharaf1038
    @aouadicharaf1038 3 місяці тому

    finished!! Amazing content ❤❤❤

  • @SohaibSanaa
    @SohaibSanaa 5 місяців тому

    I came to learn Bloc State Management and ended up as his fan. I love the way how he Explain and teach. If this course was on Udemy, he must hai Millions of Students by now. (An this course should be on Platforms like Udemy) 💯❣💫

  • @arnaudroncari2468
    @arnaudroncari2468 6 місяців тому

    Such a great teacher !

  • @VaibhavC-co1bi
    @VaibhavC-co1bi 5 місяців тому +1

    this is so awesome bloc tutorial and very clear so that developers like me can understand. Can you make a video about the features first appraoch or some project based on bloc

    • @RivaanRanawat
      @RivaanRanawat  5 місяців тому

      Will be coming soon, hopefully March!

  • @alanta335
    @alanta335 2 місяці тому

    best tutorial i heard in a long time🤩

  • @faheemahmadofficial7701
    @faheemahmadofficial7701 7 місяців тому

    Thanks great help, would like to see firebase full using clean arvh and cubit all cruds fcm cloud functions and model based work

  • @maulahaz
    @maulahaz 7 місяців тому

    MashaAllah.. very good explanation. Deep like diving in the ocean. Recommended to watch.

  • @azamovdev
    @azamovdev 7 місяців тому

    Good Bro I wish luck your works

  • @sabinpoudel6969
    @sabinpoudel6969 7 місяців тому +1

    Rivaan you are gem for a flutter community.
    Thanks for clearing my doubts.!!!

  • @faridahmadov5991
    @faridahmadov5991 6 місяців тому

    You are the best tutor ever!

  • @justetk
    @justetk Місяць тому

    Nice Video! Thanks from Azerbaijan!

  • @shhhhh.
    @shhhhh. 4 місяці тому

    Great video 👌👌👌

  • @user-rk3me5st3q
    @user-rk3me5st3q 5 місяців тому

    this is pure gold

  • @faridahmadov5991
    @faridahmadov5991 7 місяців тому

    Quite good explain

  • @PaoloTshiyole
    @PaoloTshiyole 7 місяців тому

    That's amazing, good video
    May you do a video with flutter and gemini pro api please

  • @pallabroy8800
    @pallabroy8800 7 місяців тому

    Pls make a dedicated course on fl_charts and also make a video on how to use fl_charts with api to use real time data for the graphs

  • @zaitoontech
    @zaitoontech 4 місяці тому

    Awesome thanks bro

  • @LelloApp
    @LelloApp 2 місяці тому

    it was fantastic!!! thanks

  • @z1lowf
    @z1lowf 4 місяці тому

    You are insane. Thx for everything. Im learning from u a lot.

  • @user-hq6ul4ob2z
    @user-hq6ul4ob2z 6 місяців тому

    Outstanding Explanation.....

  • @user-bg1ks1rq4o
    @user-bg1ks1rq4o 7 місяців тому

    Amazing video, that's very good

  • @madmilitiangaming5694
    @madmilitiangaming5694 7 місяців тому

    amazing content

  • @arthonuy7211
    @arthonuy7211 7 місяців тому +1

    Hey Rivaan I have a doubt in Todo app , when we first update the empty list by state.add() then emit(state) then why emit is notifying the listeners about the change? I mean todo list page should not show anything right?

  • @ramandahiya6977
    @ramandahiya6977 4 місяці тому

    well explained

  • @user-zq1il5lj4h
    @user-zq1il5lj4h 2 місяці тому

    An Advantageous tutorial.👋

  • @Revanth233
    @Revanth233 7 місяців тому

    Tqsm bro for making videos most beautiful 😍

  • @techwithotabek
    @techwithotabek 5 місяців тому

    Hey Rivaan, great tutorials brother. Can you also make a tutorial for Provider like you did for Bloc?

    • @RashidKhan-kd9xl
      @RashidKhan-kd9xl 3 місяці тому +1

      He had it.. you can see it ( in his 3rd app in 20h course of flutter for beginners) but there nothing much in providers ❤

  • @user-nt3oq6cp5n
    @user-nt3oq6cp5n 5 місяців тому

    your video is very useful!
    So, i have one Question, Is there any no need domain layer that use in clean architecture?

  • @rifkiardiansyah616
    @rifkiardiansyah616 4 місяці тому

    Bro, you saved me

  • @__basith__742
    @__basith__742 6 місяців тому

    see you should also include stream subscrption using bloc it would be
    every much appreciated

  • @ndonnayacynth1991
    @ndonnayacynth1991 2 місяці тому

    Thank you so much

  • @user-gl8mz7jm4l
    @user-gl8mz7jm4l 4 місяці тому

    can you create the video like how can we dependency inject, using the annotation, and using of json serizable and more

  • @akshatt25
    @akshatt25 7 місяців тому

    Rivaan It would be really great if you make a Spotify clone (integrating Spotofy API)
    it's API is considered to be real tough

  • @scorpionadvertising8808
    @scorpionadvertising8808 28 днів тому

    He is a better teacher than a coder😂

  • @joelmathew3253
    @joelmathew3253 7 місяців тому

    Great one

  • @nullcodeer
    @nullcodeer 7 місяців тому

    great boss...................

  • @pradeepg4498
    @pradeepg4498 7 місяців тому +1

    How to handle stream and bloc state value in another bloc

  • @jainambarbhaya1736
    @jainambarbhaya1736 7 місяців тому +1

    so which is more recommended Bloc or Riverpod ?

  • @leoe.r.7338
    @leoe.r.7338 7 місяців тому

    Thanks bro!.

  • @hurbangash1302
    @hurbangash1302 3 місяці тому

    rivan bhai next responsive design tutorail please

  • @pravinprince3221
    @pravinprince3221 4 місяці тому

    Good morning bro one more request bro can you please do detailed videos on bloc_concurrency and transformer like this one please

  • @gyanupadhyay9473
    @gyanupadhyay9473 7 місяців тому

    How to handle crud in forms using bloc?

  • @szyszak9424
    @szyszak9424 7 місяців тому

    1:37:17 when after circular loading indicator ends it shows previous screen for a bit and then goes to next one, is it a glitch or what?

  • @srhanzd3022
    @srhanzd3022 2 місяці тому

    🤩🤩🤩

  • @HGHG-yn4uo
    @HGHG-yn4uo 5 місяців тому

    You are the best 😘😘

  • @muhammadjavedrafique4592
    @muhammadjavedrafique4592 7 місяців тому

    oh yrr Rivan i dont know who told you what we need on which time 🤣🤣.... tnku Gem

  • @nidhinlalp5267
    @nidhinlalp5267 7 місяців тому

    tnks lot

  • @manulagadec6846
    @manulagadec6846 4 місяці тому

    23:40 🤣 you're the goat

  • @hiteshnath7729
    @hiteshnath7729 3 місяці тому

    Bro can you send your vscode settings json, I loved your theme ❤

  • @srhanzd3022
    @srhanzd3022 2 місяці тому

    😍😍😍

  • @anooptj9730
    @anooptj9730 6 місяців тому

    Thank You

  • @sagarshah5341
    @sagarshah5341 Місяць тому

    On 25:09 would it be a better idea to create a global object for the class CounterCubit?
    That way we only have to deal with the global instance of the state!
    What do you think?
    class CounterCubit extends Cubit {
    // int counter = 0;
    CounterCubit() : super(0);
    void incr() {
    emit(state + 1);
    }
    void decr() {
    if (state == 0) {
    return;
    }
    emit(state - 1);
    }
    }
    // after creating this object in the same file, no NEED for an extra PROVIDER at all
    final gCounterCubitObj = CounterCubit();

  • @vikashtiwari8360
    @vikashtiwari8360 7 місяців тому

    thank you soo much

  • @drreload6726
    @drreload6726 7 місяців тому

    Please give a tutorial for getx. Not able to find proper documentation.

  • @aouadicharaf1038
    @aouadicharaf1038 3 місяці тому

    ❤❤❤

  • @justinprakashraj6256
    @justinprakashraj6256 7 місяців тому +1

    ❤👏

  • @mohammadsaidi880
    @mohammadsaidi880 7 місяців тому

    love love love from Bangladesh

  • @youtubeaziz1528
    @youtubeaziz1528 7 місяців тому

    is bloc only provide global instance ?

  • @River-mm6jw
    @River-mm6jw 7 місяців тому +2

    Part 2 : Bloc + Freezed with
    Clean Architecture

  • @usmanofficial4881
    @usmanofficial4881 3 місяці тому

    Thank you so much for tutorial sir.. but getting one error in weather app after all functionality done. "int is not subtype of double"
    this error also occurred in your weather app that i got from your github and run it then same error got

  • @vikashtiwari8360
    @vikashtiwari8360 7 місяців тому

    Please make tutorial onfood ordering app or ride sharing app

  • @daveloperkrishana7559
    @daveloperkrishana7559 7 місяців тому

    what do you feel which is better bloc or riverpod for state management tool
    ?

    • @pedroluzio
      @pedroluzio 7 місяців тому +1

      try both and see which one rocks your boat

  • @parameshmamidisetti8167
    @parameshmamidisetti8167 7 місяців тому

    it's awesome

  • @kobab4270
    @kobab4270 4 місяці тому

    Thank you for this! But after finishing this, the weather app didn’t work anymore. The circular progress indicator was just circling infinitely. I tried to run your finished weather app folder on GitHub to check if I didn’t make some kind of error while following the video, but I still got an error, this time "type 'int' is not a subtype of type ‘double' in type cast"