Flutter State Management: setState, BLoC, ValueNotifier, Provider

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

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

  • @thewalkevent889
    @thewalkevent889 4 года назад

    This is a very good tutorial. I have a question. How can I use pageview or tabbarview in a stateless widget?

  • @Surimi888
    @Surimi888 4 года назад

    On the subject of ValueNotifier, in what scenario would you use ValueListenableBuilder over ChangeNotifierProvider?

    • @CuiqkOfficial
      @CuiqkOfficial 4 года назад

      When you don't want to use provider package.

    • @Surimi888
      @Surimi888 4 года назад

      @@CuiqkOfficial Could you give an example of when you wouldn't want to use provider?

  • @progamer1196
    @progamer1196 4 года назад +1

    @Andrea whenever we call 'setState()' the complete widget and its children are built, is this the same case in BLoC and provider implementation?

    • @CodeWithAndrea
      @CodeWithAndrea  4 года назад +2

      You would not normally use StatefulWidget+setState with BLoC. Rather, you would take the output stream from a BLoC and feed it to a StreamBuilder, which rebuilds your UI.

    • @progamer1196
      @progamer1196 4 года назад

      @@CodeWithAndrea Ok thanks. Actually my real issue is that I am loading a lot of network images in a widget (around 100), so if I load them through stream builder (say by providing the image url), will it make the network call again when the widget is being rebuilt (like during push, pop navigation)?

  • @uttamgondaliya2757
    @uttamgondaliya2757 5 лет назад +1

    hi bro
    flutter full course?

  • @belqisshida5345
    @belqisshida5345 5 лет назад

    how to avoid unnecessary rebuilds? example:
    Widget A.
    Widget B.
    Widget C.
    Here when I update a state in Widget A with provider, the Widgets B and C rebuilds too.
    So how to avoid unnecessary rebuilds in B and C ?

    • @CodeWithAndrea
      @CodeWithAndrea  5 лет назад

      Keep an eye of my upcoming videos on Provider. I cover this issue there.

  • @snooringcode6594
    @snooringcode6594 4 года назад +2

    So which one is a good choice to go with?

    • @CodeWithAndrea
      @CodeWithAndrea  4 года назад +5

      Depends in your use case. I often use Provider+ChangeNotifier for local state that needs to be shared across widgets, and Provider+Bloc when working with streaming APIs (e.g. Firebase).

    • @snooringcode6594
      @snooringcode6594 4 года назад

      @@CodeWithAndrea Can we achieve the size of flutter apps just like native android or ios app sizes?

  • @martymcfly6164
    @martymcfly6164 5 лет назад

    Hi Andrea, I have a problem with the Stream builder authentication with firebase. I followed your tutorial "Flutter & Firebase authentication with streams and StreamBuilder", everything works fine, except the HomeScreen is not returned visible when I log in on a different page than the SignInPage (I pushed a new route to a SignUpPage). The reason is (as far as I understand) that HomeScreen and SignInPage are only switched below, invisible, under the SignInPage. What is the best solution to fix this?
    Thanks in advance!

    • @CodeWithAndrea
      @CodeWithAndrea  5 лет назад

      Hi Marty. You are correct, this is what happens when you push a new route. The best way to address this is to add a call to Navigator.pop() right after the sign in call succeeds. That way the page is dismissed and you are taken to the HomePage.

  • @WhatIsThisAllAbout
    @WhatIsThisAllAbout 4 года назад

    Thanks Andrea for making such highly informative videos on flutter.

  • @hectorprx
    @hectorprx 4 года назад

    Thanks Andrea for distilling 2 years of effort

  • @nicolaszein
    @nicolaszein 4 года назад

    Hello Andrea, do you do freelance work?

  • @emyboybeats4330
    @emyboybeats4330 5 лет назад

    which is better for scaleable apps setState, BLoC, ValueNotifier, Provider?

    • @CodeWithAndrea
      @CodeWithAndrea  5 лет назад +4

      Emyboy Beats It depends. For local application state, I recommend Value/ChangeNotifier + Provider. If you have a real-time backend, or stream-based APIs, then BLoCs work well. And StatefulWidgets + setState when working with text input & forms.

    • @emyboybeats4330
      @emyboybeats4330 5 лет назад

      @@CodeWithAndrea Okay thank you.