Flutter State Management Guide - What you need to know

Поделиться
HTML-код
  • Опубликовано: 9 окт 2024

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

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

    Channels like yours make learning easy

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

    Thanks for creating this video. You started out very well, easy to follow but you went into chaos mode in the middle of the video. I couldn't keep up with all the code changes :/

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

      it helps to follow along with the written blog

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

      I also didn't understand why such a hurry. Even pausing 100x did not really help.

  • @i.k.shaikh3772
    @i.k.shaikh3772 3 года назад +6

    Good job 👍🏼

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

    Wow! After so much confusion this video really made it a little easier to understand state management to me thanks 😊🙏

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

    Does the Provider package have negative impact on performance? Is there anything about it? Thank u for video

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

    Why all this things are needed. When setstate does the job

  • @SharukhKhan-sd7xg
    @SharukhKhan-sd7xg 3 года назад +2

    Hey nice video. Please make a video on Getx. And a quick question should I go with Getx or Provider really confused.
    Thanks 👍

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

      Haven't really tried out Getx but I know that @Amateur Coder has a lot of videos on it!
      My recommendation is to go with Provider, then you will get used to a normal approach as it's just an abstraction of Inherited Widget with some bonus features. I personally use Riverpod but it's not completely stable yet :)

    • @SharukhKhan-sd7xg
      @SharukhKhan-sd7xg 3 года назад

      @@RobertBrunhage hi thanks for the quick answer really appreciate it. And thanks for the advice I'll try it out 😃

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

      @@RobertBrunhage Can you share what were the stability issues you faced with Riverpod?

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

      @@hawkybae Not something I am aware of. This is just what the readme states as of now.
      "Riverpod recently left its experimental status, but it isn't fully stable either." This is quoted from the readme :)

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

    Thanks man ❤️. Nicely explained.

  • @thorvaldresearch1093
    @thorvaldresearch1093 3 года назад +6

    I honestly think it's exhaustive as someone coming from web dev going into Flutter. Far too many packages, it's messy and something should be agreed upon. Compare this to how Vue handles the state management topic. There's Vuex. Literally that's it, and it works perfectly. When you don't unify people on the topic, all content online will be explained differently, e.g tutorials and what not.

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

      The recommendation is to just pick Provider, if you don't want to bother with all the State Management solutions. This video's goal was to show WHAT state management is and not which approach is best.
      But my recommendation is the same as Google here and that is just to pick up Provider and be efficient with it. If you want to try something new later on, then it's up to you! 😊

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

    Amazing videos. Can you please tell us how should we do the more secure authentication by which pattern or tool. because authentication is something where beginners suffers. and also after authentication we need to use the info of the logged in user. so which way we should use provider or use of firebaseuser.currentuser please explain basics in some video. thank you

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

    I like the way of your explanation, but u are a little bit faster which makes it hard to catch up, i wish if you work on provider tut with a little lower pace 🙏🙏, anyways thank you very much robert

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

      I will see if I can slow down and give better explainations in my next video. Thanks for the valuable feedback!

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

      Thanks

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

    Nice tutorial Robert! What is a more better state management? Bloc or Provider?

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

      Doesn't really matter about what is better, the better one is the one you are more productive with. Try out both and see which one you prefer! 😊

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

    Maybe I’m old school but in one of my recent projects, I used an inherited widget and a value notifier 🤷🏻‍♂️🤷🏻‍♂️

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

      I remember when I started and there was only InheritedWidget. Oh god that was hard to grasp back then haha!

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

      You are not alone, that's what I'm doing all along, especially for animated widgets.

    • @1c72
      @1c72 3 года назад

      Same. The thing with Provider is that, I don't know what people do for multiple variables/fields. I'm using ValueNotifier for each field, so why do I need to use an external library when InheritedWidget is just as easy. If I use simple data types for each field, like String or int, and then watch on the provider, then whenever any field changes, other parts watching other fields are also rebuilt.

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

      @@1c72 provider has a selector widget now which prevents unnecessary rebuilds

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

      @@sadhlife Thanks for the reply. But I still don't understand what's something Provider is good for but ValueNotifier and InherentedWidget won't do just as easily and elegantly?

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

    Instant sub, great matetials.

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

    Flutter is very easy framework and state is very simple concept change data in one place and will be changevin all widget tree
    In the web component tree that' s all, and there is enough libraries for that
    Why every make such is complex thing
    And for all most mobile app you can use set state ........

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

      It's not a simple concept if you haven't worked with these kind of frameworks before. Probably this most questions I get is "Why is the widget not showing the change of my data".
      SetState is fine but can be quite hard to manage as the application grows, imo.

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

      I would like to see reactivity built into the dart language in a similar manner Svelte 3

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

    That was an awesome video. Thank you, Robert!. Robert May I ask if you a shoot video about Amazon amplify integration with Flutter apps. And Also How to use a Python script in a flutter app. Best wishes.

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

      Amazon amplify is on my list for sure!

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

      @@RobertBrunhage You are the Man!. Grateful for that. That'd be awesome if It becomes beginner-friendly tutorial🙈💎💎💎

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

    Whats it the most approach like React.useEffect for Flutter`s method . If i need to track some state e do some stuff when state change. In flutter we have something like that? is i thinking in the wrong way?

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

    Nice informative video. I like how you tried to simplify the process.

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

    I really liked this. But bigger text would have been nice

  • @fille.imgnry
    @fille.imgnry 3 года назад +2

    What is the problem with simply putting state in a separate Class in a separate file. In the end of the file instantiate the class and store it in a public variable. Have Streams, Valuenotifiers or whatever you want in this class and then just import that variable wherever you need. What is the benefit of accessing state through the widget tree instead of directly from another module/file ?

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

      You can do it however you want, this is to showcase what state management "is".

    • @fille.imgnry
      @fille.imgnry 3 года назад +2

      @@RobertBrunhage Ok. I am just a bit surprised and confused. I have watched perhaps 20+ videos around Flutter state management and none of them recommends doing it this way or even mentioned that it is possible, so I thought that it has to be something that I am missing but after using this simple techique for a year of development now I still have not bumped in to any disadvantages. Just thought you might have some idea about what I could be missing. Well, keep up the good work! :)

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

      ​@@fille.imgnry I am not saying that the way you are doing it is wrong or that this is right, or that this is the approach I recommend that you do it.
      This video is not supposed to show the best way to this this or the most optimal way of doing it. It's just a way to explain what is happening. And it's in fact that when data changes that is listened to the trees are compared, sees a change and the build method is called. When the build method is called it will show the new data on the screen.
      You are talking about how to architecture and where to put the state but that doesn't change the fact of what is happening when the widget gets notified of a change and rebuilds.
      Hope this makes more sense!

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

      Hey @Fille I agree 100% with you - this is the whole question. @Robert Brunhage, I don't think you should diminish this question, rather explore it. I have another one to add: addressing the state by a single type (everything is a singleton) is a unnecessary restriction. I want a many-to-many relationship of widgets referencing state objects using a key/id.

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

      ​@@alisterlee5643 I do not really follow, the video is not adressing achitecture but instead what state management is. How you go about that is up to you. If you don't want to reference by type then you do not use InheritedWidget but instead something else like Riverpod (where you are not limited by type).
      I have not looked in to what you specifically want but I think you get the point :)
      Also I am not diminishing the question (not my intention at least), that is why I answer it as best as I can 😊

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

    Nice !

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

    Say I'm retrieving data from an API. Can I just use value notifiers to update the text UI elements when, say, a refresh of the data is initiated? Rather than have a bunch of stateless widgets passing the updated values?

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

      When you give a ValueNotifier new data and that ValueNotifier is listened to with for example a ValueListenableBuilder the UI will update.
      ChangeNotifiers is also an approach here where you call a method on that and when the request is complete you can call notifyListeners (all listeners will update).

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

    Can you tell me the cons of GetX?

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

    0:50 Inject our information to flutter tree

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

    try mobx dart

  • @NPC.98
    @NPC.98 3 года назад

    Cool😎

  • @dalpatsingh5262
    @dalpatsingh5262 7 месяцев назад

    आईएचएम कॉलेज जोधपुर राजस्थान अंग्रेजी की क्लास में भी टीचर हिंदी मारवाड़ी बोलते हैं

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

    chaos

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

    Whats new in this though...

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

      Nothing is new, this is explaining what state management is and how it works, doesn't have to be new for that 😉

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

      @@RobertBrunhage sure, but you have already explained it before no?

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

    I thought you gonna make some visual example too so you can prove to newbie like me to understand State Management.
    Like comparing the stateful widget you made earlier and change it to stateless widget but it still works the same, but no visual at all.
    Disappointed.

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

      That is specifically shown in the video. We move from a Stateful Widget to a Stateless Widget with the help of a ValueNotifier. Is there something else you would have wanted to see, or did you want to see the app before and after with those two approaches?
      All feedback is greatly appreciated! 😊

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

      @@RobertBrunhage Yes, I wanted to see the before and after the change.
      Maybe I should say 'we'. Because visual cue very useful to us.
      And thank you to you too sir.

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

      @@muhammadyusoffjamaluddin Thank you for he super valuable feedback, I will think extra about this for the future videos for sure!

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

      Why don't you invest more time on some actual reading or investing on paid courses as well?
      It's ridiculous you're saying this is 'disappointing' while he his practically giving his knowledge for free.