Moving from setState to Riverpod in Flutter Part 1

Sdílet
Vložit
  • čas přidán 9. 07. 2024
  • If you're interested in learning Riverpod, you've probably already learned a little bit about Provider. Riverpod was created by the same guy that created the Provider package. Also if you haven't notice, Riverpod is an anagram of Provider. This video will get you started with Riverpod and show you why it's a major upgrade from Provider.
    00:00 - Intro
    00:24 - Overview with the basic setState approach
    04:09 - Creating a Provider, FutureProvider, and StreamProvider
    08:29 - Showing a value using context.read()
    10:00 - The Consumer widget and FutureProvider
    15:47 - Using a StateNotifier to hold state
    21:35 - Creating the StateNotifierProvider
    23:05 - Adding list state
    25:50 - Watching the list state
    27:23 - Deleting list items and testing
    30:28 - Use StreamProvider to display a stream of values
    💻Follow along here with the initial code: github.com/theflutterfactory/...
    ⚡Connect on Facebook: / flutterfactory
    ⚡Connect on Twitter: / flutterfactory
    🎷Music: www.bensound.com

Komentáře • 28

  • @FlutterMapp
    @FlutterMapp Před 2 lety +2

    Thanks man for the vid 🔥

  • @madhankanakamani3725
    @madhankanakamani3725 Před 2 lety

    Thanks man,
    Finally i found how to create and use StateNotifier effectively from this video
    thanks a lot for this 🤞

  • @dasaintgray
    @dasaintgray Před 2 lety +3

    Thank you so much, i really appreciate your work, it helps me a lot on my current project. Keep up the good work Master....

  • @juanmacias5922
    @juanmacias5922 Před 2 lety

    Great in depth, and to the point video!

  • @franciscoruiz9460
    @franciscoruiz9460 Před 2 lety

    Very nice tutorial! Thank you.

  • @omalperera
    @omalperera Před 2 lety

    Great video. simply explained

  • @fluttercode4236
    @fluttercode4236 Před 2 lety

    Good work.thank you😀

  • @MartinJahn
    @MartinJahn Před 3 lety +2

    I'm just looking for a way to manage state. I've tried bloc which I didn't like. Riverpod looks much more promising. This video definitely helped.

  • @luisalbertomartinezgarcia3012

    pls part 2
    thaaaaankssss !!!

  • @KrastyoKrastev
    @KrastyoKrastev Před 3 lety +2

    Thank you! Finally understood the basics thanks to this video! Now I can build my first app with the Future provider :)

  • @ani-singh
    @ani-singh Před 2 lety +2

    In case userList is not working, add "as List" to userList-
    final userList = ref.watch(userListProvider) as List;

    • @gorochan6087
      @gorochan6087 Před 2 lety

      awesome! my problem is solved.thank you so much

  • @francescofreddi4374
    @francescofreddi4374 Před 3 lety +1

    i love youuuuuuuuuuuuuu

  • @user-zi3nf1cv1z
    @user-zi3nf1cv1z Před 3 lety +1

    Hello. Very useful video. Is it possible to make global provider (for example: when user tap on listview item, this value i want to show on every further screen. I tried make global provider inside OnTap method, but a i can't get access to it in another screen anyway )in one screen and get it's value on another screen? P:S: Sorry for my english )

  • @yusufumar6738
    @yusufumar6738 Před 2 lety

    thanks a lot for this amazing tutor. please how can someone use a boolean with either StateProvider or StateNotifierProvider, i have tried something like this "final isPro = StateProvider((ref) => false);" and tries to watch like this " bool test = watch(isPro);". . . so i got the error. "The argument type 'StateProvider' can't be assigned to the parameter type 'ProviderBase

  • @zayaerme
    @zayaerme Před 2 lety

    26:30 they have changed something in the Matrix or just editing error😅

  • @ericchua3492
    @ericchua3492 Před 3 lety +1

    Weird, when I restart the application, it shows me this instead
    Restarted application in 278ms.
    flutter: Home rebuilding...
    flutter: UserList rebuilding...
    flutter: Home rebuilding...
    flutter: UserList rebuilding...
    I follow your video step by step, any idea?

    • @TheFlutterFactory
      @TheFlutterFactory  Před 3 lety +1

      I didn't optimize for rebuilds. That was my fault. I was too focused on the riverpod funcationality itself. One thing to note is that watching a provider at the top of your build function will rebuild the entire widget (and any child widgets)

  • @martinbohling6366
    @martinbohling6366 Před 2 lety

    Finally figured out "Why doesn't it work when I try it?" There are breaking code changes between the version of riverpod in the video (mid 2021) and v1.0.0 which came out in August 2021. It's almost impossible for video tutorials to stay up-to-date in the flutter world. Poor guy now has the choice: Reshoot the video so that it is once again a top tutorial for this package, or simply accept that it's "mostly correct, but won't actually run" if you install the latest version of riverpod.

  • @ezone2726
    @ezone2726 Před 3 lety +1

    Need more tutorial on flutter_riverpod.
    Thank you.

    • @TheFlutterFactory
      @TheFlutterFactory  Před 3 lety +2

      soon

    • @ezone2726
      @ezone2726 Před 3 lety +1

      @@TheFlutterFactory hope you will share more series flutter_riverpod very soon and we are excting too much❤️

  • @RandalLSchwartz
    @RandalLSchwartz Před 3 lety +2

    Your use of context.read() early in the screencast (around 8:30) to get the Cheetah Coding value is probably misleading. If the provider of that value ever changes the value, your view would *not* be updated. It should have used a "watch" instead. Remi has commented on this "fear of watch" behavior, even referencing it in the official docs.

    • @TheFlutterFactory
      @TheFlutterFactory  Před 3 lety +1

      For a constant value, it's ok here since the output will be the same. I get your point though. Old habits from Provider.

    • @TheFlutterFactory
      @TheFlutterFactory  Před 3 lety +1

      I appreciate all your input on this. I know you've been a big advocate for RiverPod online.

  • @wenyeh24
    @wenyeh24 Před 3 lety +1

    github link error