Это видео недоступно.
Сожалеем об этом.

#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

Комментарии • 78

  • @Flutterly
    @Flutterly  3 года назад +5

    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

  • @AndreKiller1993
    @AndreKiller1993 3 года назад +20

    I switched from Provider to Bloc thanks to your videos. Best decision I've ever made!

    • @Flutterly
      @Flutterly  3 года назад +2

      It's funny I made the same decision about 1 year and a half back haha 😂

    • @vishantjaiswal8146
      @vishantjaiswal8146 3 года назад +2

      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.

    • @Flutterly
      @Flutterly  3 года назад +2

      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" !

  • @nhexplorers
    @nhexplorers 2 года назад +7

    Would love it if you updated this course to Bloc 8 !!

  • @aurelagbodoyetin3321
    @aurelagbodoyetin3321 3 года назад +9

    The guy I were waiting for 😂
    Thanks bro 😊

    • @Flutterly
      @Flutterly  3 года назад +2

      😂 😂 Appreciate it, brother!

    • @aurelagbodoyetin3321
      @aurelagbodoyetin3321 3 года назад +1

      Keep helping us improve our bloc skills
      You are the best 👏

  • @dnlbrock
    @dnlbrock 3 года назад +3

    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.

    • @Flutterly
      @Flutterly  3 года назад +1

      Thanks, man, indeed, the following videos will again, be mostly about mistakes to be avoided

  • @Add0w
    @Add0w 3 года назад +2

    I updated before but I like to watch those wonderful lectures of u. Thank you very much and keep teaching us these wonderful concepts.

    • @Flutterly
      @Flutterly  3 года назад +1

      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!

    • @Add0w
      @Add0w 3 года назад +1

      @@Flutterly No problem thanks for your time and the wonderful info.

  • @vishantjaiswal8146
    @vishantjaiswal8146 3 года назад +1

    thanks for making it easier to understand the diff between watch and select

    • @Flutterly
      @Flutterly  3 года назад

      You are welcome, mate!

  • @thang1144
    @thang1144 3 года назад +2

    Thank you for making videos about Bloc, its very helpful and easy to understand

  • @faizc359
    @faizc359 Год назад

    Your videos are super easy to understand.

  • @babimalas2400
    @babimalas2400 3 года назад +2

    One of the best flutter channel on RUclips! Thanks for your hard work man

    • @Flutterly
      @Flutterly  3 года назад

      Really appreciate it, man, thanks! 🌟

  • @diman9918
    @diman9918 3 года назад +1

    best explanation i have got seen till now, waiting for next video you are really helpful

    • @Flutterly
      @Flutterly  3 года назад

      Thanks a ton! I appreciate it!

  • @timatikgz5310
    @timatikgz5310 3 года назад +2

    Thank you for your efforts 👍 with picture I understood more effective

    • @Flutterly
      @Flutterly  3 года назад +1

      I'm glad to hear that! Thanks!

  • @j3ns
    @j3ns 3 года назад +1

    Awesome video! Thanks for these good explanations.

    • @Flutterly
      @Flutterly  3 года назад

      Thank you so much! ✨

  • @user-qz8es8sm1n
    @user-qz8es8sm1n 3 года назад

    thanks, your tutorials are great!

  • @MohamedAbdallah-oh4ux
    @MohamedAbdallah-oh4ux 3 года назад +1

    Great videos thanks for the explanations. keep up the good work 💪

    • @Flutterly
      @Flutterly  3 года назад +1

      Thank you a ton! I'll keep them coming!

  • @Pedro5antos_
    @Pedro5antos_ 2 года назад

    Thanks for sharing!

  • @user-pv3gy3ek4x
    @user-pv3gy3ek4x Год назад

    Best bloc tutorial!

  • @islomkhujaakhrorov6668
    @islomkhujaakhrorov6668 3 года назад +1

    It is going nice with your videos)

  • @abrorbobomurodov2361
    @abrorbobomurodov2361 3 года назад +1

    thank you bro, I love your lessons

  • @michakozak1767
    @michakozak1767 3 года назад +1

    I highly recommend this guy. Just a little focus and magic happends 🔥🔥🔥

  • @Kolano666
    @Kolano666 3 года назад +2

    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.

    • @Flutterly
      @Flutterly  3 года назад

      Yup, I started to remove the hand from tutorial number 12. Thanks for your amazing feedback!

  • @abdurahmon2827
    @abdurahmon2827 Год назад

    Thank you for such a usefull video

  • @geraldcampana9296
    @geraldcampana9296 3 года назад

    What the heck, i always use buildWhen. :) Thank you, I learned new today.

  • @navarasan8264
    @navarasan8264 3 года назад

    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.

    • @Flutterly
      @Flutterly  3 года назад

      Unfortunately, I don't understand your question, mate. Can you be more specific?

    • @navarasan8264
      @navarasan8264 3 года назад

      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?

    • @Flutterly
      @Flutterly  3 года назад

      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.

  • @gabrieled2523
    @gabrieled2523 3 года назад +4

    Will you do videos about API with Bloc?

    • @Flutterly
      @Flutterly  3 года назад +9

      In the next tutorial series I will start making real world apps with bloc, it's going to be a fun one.

    • @techstudio7331
      @techstudio7331 3 года назад

      @@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

  • @pedrodelacruz2369
    @pedrodelacruz2369 3 года назад +1

    Thanks men!!! 💪😎

    • @Flutterly
      @Flutterly  3 года назад

      You're welcome, man!

  • @nick0c
    @nick0c 3 года назад

    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?

    • @Flutterly
      @Flutterly  3 года назад +1

      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.

  • @rohitsrao
    @rohitsrao 2 года назад

    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 ?

  • @oguzcc
    @oguzcc 3 года назад +1

    Thanks!!

    • @Flutterly
      @Flutterly  3 года назад +1

      You're welcome, Oguz! Thank you!

  • @keithbacalso9433
    @keithbacalso9433 2 года назад

    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?

  • @Add0w
    @Add0w 3 года назад

    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.

    • @Flutterly
      @Flutterly  3 года назад +1

      That was exactly what I was about to cover in the next tutorial, haha, we synced our minds pretty well! No problem, bro

    • @Add0w
      @Add0w 3 года назад

      @@Flutterly I was wondering if we can use hydrated bloc instead of sharedprefrence for storing token ....to be honest I didnt try it hh.

  • @ashrafabdo5461
    @ashrafabdo5461 Год назад

    thanx

  • @officialismailshah
    @officialismailshah 2 года назад +1

    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???

  • @noshingh521
    @noshingh521 3 года назад

    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)?

    • @Flutterly
      @Flutterly  3 года назад +1

      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.

  • @hatemragab2902
    @hatemragab2902 3 года назад +1

    thanks brooo

    • @Flutterly
      @Flutterly  3 года назад +1

      You're welcome, brother!

  • @delmontee
    @delmontee 6 месяцев назад

    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

  • @a7mdFathii
    @a7mdFathii 3 года назад

    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

    • @Flutterly
      @Flutterly  3 года назад +1

      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 ?

  • @kousikambani4499
    @kousikambani4499 3 года назад +2

    Hey what is going on everyone !!

    • @Flutterly
      @Flutterly  3 года назад +2

      This is WCKD and today... 😂

  • @-RimuruTempest
    @-RimuruTempest 3 года назад

    If you have time pls teach us fundamentals of widget tree and element tree.

    • @Flutterly
      @Flutterly  3 года назад

      I covered this topic in my tutorial no. 8, mate, regarding BuildContexts

    • @-RimuruTempest
      @-RimuruTempest 3 года назад

      @@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

  • @asiiii123
    @asiiii123 2 года назад

    as always the content is great but the tempo of the lecture is extremely fast - please try to slow a bit