Riverpod Tutorial 01 - Understanding the different notifiers

  Рет қаралды 30,985

Fun with Flutter

Fun with Flutter

3 жыл бұрын

Getting to grips with everything Riverpod has to offer is not easy. This series is here to help. In this video we explore StateNotifier, ValueNotifier and StateProvider. Three different ways to manage state in your Flutter application using Riverpod. There are of course more ways, but these are three easy and common ones.
--
Riverpod Tutorials and code:
github.com/funwithflutter/riv...
--
Check out my Flutter Animation and Performance course.
Discounted link: bit.ly/funwithcourse
Or use the promo code: FUN
for a discount at checkout: courses.funwith.app
--
Join me on the socials.
Twitter: / gordonphayes

Пікірлер: 85
@CagatayOncul
@CagatayOncul 3 жыл бұрын
Best video about riverpod. Its better then official video. Thanks
@lucasneuhaus3138
@lucasneuhaus3138 3 жыл бұрын
Dude, big thanks. It feels like everywhere else they always fly through the different types of providers and always use primitives. Awesome explanation.
@SyntacOps
@SyntacOps 3 жыл бұрын
Wow. Love the way how you explain it and cover different scenarios. Can't wait for the next part.
@hypen-io
@hypen-io 3 жыл бұрын
Amazing tips to prevent unnecessary build() by `const Something()`. That saves a lot of performance! Thanks!
@hypen-io
@hypen-io 3 жыл бұрын
BTW, are you still maintaining your patreon? I have not been patreon since I got unemployed. But I would like to join it again :)
@FunwithFlutter
@FunwithFlutter 3 жыл бұрын
Thanks for the interest man. For the time being I'm putting it on hold while I focus on other things :)
@federico9505
@federico9505 3 жыл бұрын
Looking forward to watching the next episode!
@randomusername982374
@randomusername982374 2 жыл бұрын
You did a great job explaining riverpod; your content flows nicely. Many others on youtube have rushed through the explanation on riverpod so I'm glad I found these videos!
@FunwithFlutter
@FunwithFlutter 2 жыл бұрын
I'm glad you like the pace of these. Something I tried to focus on in this series
@doulainc.498
@doulainc.498 2 жыл бұрын
I'm about to watch this. Yay let's go
@Gabzim
@Gabzim 2 жыл бұрын
Thank you for the great content, I looked around quite a bit before I could find somebody covering riverpod with this level of depth. Subscribed!
@enricllopis9304
@enricllopis9304 2 жыл бұрын
Best youtube video on youtube, thank you!
@FunwithFlutter
@FunwithFlutter 2 жыл бұрын
😊😊😊
@sergdigital7437
@sergdigital7437 3 жыл бұрын
Riverpod is brilliant! Your explanation is a masterpiece!
@FunwithFlutter
@FunwithFlutter 3 жыл бұрын
Ohhh yeahhh
@RobertBrunhage
@RobertBrunhage 3 жыл бұрын
Great video, and the explainations are excellent! Keep up the amazing work :)
@FunwithFlutter
@FunwithFlutter 3 жыл бұрын
Thanks😊
@Steph-sm5pb
@Steph-sm5pb 3 жыл бұрын
South African??
@tadaspetra
@tadaspetra 3 жыл бұрын
Lots of great information here! Great video
@lubshadpattarathil280
@lubshadpattarathil280 2 жыл бұрын
You are a great teacher ❤️❤️
@FunwithFlutter
@FunwithFlutter 2 жыл бұрын
👨‍🏫 thanks
@BrendansReasons
@BrendansReasons 2 жыл бұрын
Thank you for being practical
@stephaniesutherland4740
@stephaniesutherland4740 2 жыл бұрын
As a South African living in UK, learning Riverpod with your accent is wonderful! 'Bare with me, hey'
@FunwithFlutter
@FunwithFlutter 2 жыл бұрын
Hahaha that's awesome to hear. Sometimes I can't keep the South African in control. I sometimes also drop Afrikaans words by accident.
@stephio76
@stephio76 3 жыл бұрын
Excellent explanation and I can't wait for the next one! Thank you!
@FunwithFlutter
@FunwithFlutter 3 жыл бұрын
Glad you like it!
@samario_torres
@samario_torres 3 жыл бұрын
Best segway I’ve ever seen in the beginning lol
@rydmike
@rydmike 3 жыл бұрын
Simply outstanding explanations, never before seen such a clear explanation of the differences between these three Riverpod providers. It’s like the missing manual for Riverpod’s beautiful docs. Can’t wait for the rest of this series. If they are at this level, which I am sure they will be, you should do some kind of collab with Remi so he can point readers to the videos in the Riverpod docs. 👍💙
@FunwithFlutter
@FunwithFlutter 3 жыл бұрын
Thanks so much for this comment. Really appreciate it. Will definitely let Remi know about the series at some point. Maybe when it's a couple of videos in
@alexanderperepelitsyn8851
@alexanderperepelitsyn8851 3 жыл бұрын
That’s the best explanation!
@FlutterMapp
@FlutterMapp 2 жыл бұрын
Well done 🔥
@FunwithFlutter
@FunwithFlutter 2 жыл бұрын
Big fan of your content!
@FlutterMapp
@FlutterMapp 2 жыл бұрын
@@FunwithFlutter Same here!
@husseinalmosawi2001
@husseinalmosawi2001 3 жыл бұрын
Awesome series! And please, can you make a video about flutter localization? Especially being able to convert the app to RTL...
@MonsieurMouche
@MonsieurMouche 3 жыл бұрын
Awesome tuto, thanks a lot!
@FunwithFlutter
@FunwithFlutter 3 жыл бұрын
You're welcome!
@hawkybae
@hawkybae 3 жыл бұрын
Great stuff! I'm already in the middle of development of an app using Provider and thinking of migrating to RiverPod! Would love to see a video about tackling API calls in a future video :)
@FunwithFlutter
@FunwithFlutter 3 жыл бұрын
Riverpod handles API calls (futures) easily!
@thefellowbreather
@thefellowbreather 2 жыл бұрын
Great video. Although I have a question. Why did it stop updating everytime just when you switched to the "const" constructor?
@hectorprx
@hectorprx 3 жыл бұрын
Very Nice Thanks
@scottbarden4185
@scottbarden4185 3 жыл бұрын
That was a good video, thank you. Though if I never see another counter app example, it will be too soon! :) I think things start to become trickier when we introduce async actions and having state derived from some other asynchronous state (ala AsyncValue). Knowing when to differentiate between FutureProvider and a StateNotifier that manages futures internally will be interesting.
@FunwithFlutter
@FunwithFlutter 3 жыл бұрын
Ahh man perfect question. The third video of the series will come out in the next couple of days and will address this. Super excited about the video because it'll have a bunch of great tips to handle this!
@codeVictor
@codeVictor 3 жыл бұрын
Respect🙌🙌
@kalderDean
@kalderDean 3 жыл бұрын
Thanks for explaining the differences thoroughly!! It greatly helped!! Quick question though can you explain why"const Something()" restricts rebuilds. Thanks!
@FunwithFlutter
@FunwithFlutter 3 жыл бұрын
Because it’s const, when Flutter rebuilds a part of the widget tree and then it goes down that part of the widget tree it can be certain that the const widgets have already been built and doesn’t need to be again.
@remirousselet6867
@remirousselet6867 3 жыл бұрын
Awesome explanation! Fancy adding it to the doc?
@FunwithFlutter
@FunwithFlutter 3 жыл бұрын
Glad you think so! Yeah definitely, will add it to the docs. I've been using Riverpod in production the last two months and have learnt a thing or two. It's still my intention to create a Riverpod series. If you have ideas, or know of struggle areas, please let me know.
@dhanniekristanto
@dhanniekristanto 3 жыл бұрын
Very informative. thanks! Looking forward for more videos about riverpod's use case. By the way, what do you think about GetX?
@FunwithFlutter
@FunwithFlutter 3 жыл бұрын
Haven't used it😊
@faisalmushtaq2287
@faisalmushtaq2287 3 жыл бұрын
Can you please make an real world example app, such that we could clear the concepts like where to use and how to use
@billiardoxx
@billiardoxx 3 жыл бұрын
Hi! Good video. As an user of GetX I am trying to find a powerful reason why I should use Riverpod. After viewing your video I think that could be done in GetX in a more simple way. When I ask Riverpod fanboys about why I should choose Riverpod over GetX, they end up frequently saying "it make safer your code" BUT how does it? I'd love to find a video where they compare both packages (pros & cons) in performance, security, etc; it 'd be more educational, IMHO.
@FunwithFlutter
@FunwithFlutter 3 жыл бұрын
At the end of the day use whatever gets the job done. Don't think we should be idealising (or fanboying) any of these frameworks. People are also wired differently. One person may feel more comfortable with GetX and another with Riverpod (to each their own). The "makes your code safer" bit you mentioned is more relevant with regards to Provider -> Riverpod. Not sure if or how this applies to GetX. But Riverpod has compile time safety when it comes to accessing providers. The OG Provider didn't have that and you might often get runtime exceptions saying that you cannot access a particular provider (because the widget you're trying to access it from is in a different part of the widget tree, which is not a problem with Riverpod). You should make a video or blog post on the comparison between Riverpod and GetX. I'd watch/read it. I gave GetX a shot a while back and I was immediately put of when I used the easy routing it provides. The default route transition looked like trash, and that's because it doesn't use the default MaterialRoute transitions (which I expected it to). Sh*t reason to stop using the package as a whole, but that annoyed me and I felt like the package is trying to do too much hand holding and too much at the same time (which may be perfect for a beginner Flutter developer). I know you can opt in to only use the state management that GetX provides, but I like Riverpod :) and it solves the problems I had with Provider. I also like Flutter as is, and don't think it's necessary to create wrapper Widgets for everything I feel Flutter does well on its own. TLDR; Seeing as I went through the effort of typing ALL of this, maybe I am a Riverpod fanboy and you shouldn't listen to me. Use whatever you like to use or whatever gets the job done.
@billiardoxx
@billiardoxx 3 жыл бұрын
@@FunwithFlutter Thanks for your thoughts.
@thesaulo14
@thesaulo14 3 жыл бұрын
thanks
@FunwithFlutter
@FunwithFlutter 3 жыл бұрын
You're very welcome
@TrietBui
@TrietBui 3 жыл бұрын
Thanks for this useful video. Just one more question: how do we destroy or keep the *Provider? For example in ChangeNotifierProvier screen, I see by default each time you enter, its counter value is reseted to 0. But if you want to keep its previous value, how do we need to change?
@FunwithFlutter
@FunwithFlutter 3 жыл бұрын
Thanks for the question. That's only happening because I'm using three separate providers on the three different screens to demo the different ways of creating a counter. The state is being maintained, it's just three separate states. I'm sure somewhere in the video I navigate back to a screen where the count value has already been incremented. If you want to dispose of it then you should take a look at autoDispose on a Provider.
@BrendansReasons
@BrendansReasons 2 жыл бұрын
14:25 exactly, what is the drawback of just doing that
@IAmTheMainCharacter
@IAmTheMainCharacter 3 жыл бұрын
Nice effects, how did you made those.
@FunwithFlutter
@FunwithFlutter 3 жыл бұрын
Depends on which ones you're talking about. But I got a lot of the stuff from MotionArray.
@quicksketch1617
@quicksketch1617 3 жыл бұрын
It has the video about chagenotifier observers:[]?
@MoAdel92
@MoAdel92 Жыл бұрын
if it is possible to redo this series with riverpod 2?
@prince-sonawane
@prince-sonawane 3 жыл бұрын
Waiting for the part where you can tell more about how it replace multi provider concept.
@FunwithFlutter
@FunwithFlutter 3 жыл бұрын
There's no need for a multiprovider. All the providers are automatically provided
@samueloluwatodimu6963
@samueloluwatodimu6963 3 жыл бұрын
I loved this video will you be showing us a real world example like the official marvel app on the riverpod official website , that should be fun
@FunwithFlutter
@FunwithFlutter 3 жыл бұрын
Eventually I want to do an app from scratch
@deepmondal8564
@deepmondal8564 3 жыл бұрын
You are great! but is Riverpod ready to be used in production?
@FunwithFlutter
@FunwithFlutter 3 жыл бұрын
I think so! And I'm using it in prod
@_undecided
@_undecided 3 жыл бұрын
Nice video like always 👌 But I wonder when you can't use StateNotifier?
@FunwithFlutter
@FunwithFlutter 3 жыл бұрын
One situation for me was when the state was a map of key value pairs. And I wanted to have better control of when to call notifyListeners depending on when the map updated. The map would also update frequently, so it felt like a waste of resources to make the map immutable
@_undecided
@_undecided 3 жыл бұрын
@@FunwithFlutter Hmm. I have not tried it. A map is an object a list of key values ​​there should be no problem with the State Notifier. I do everything with StateNotifier but to more easily handling state I use AsyncValue and Freezed or just copyWith().
@FunwithFlutter
@FunwithFlutter 3 жыл бұрын
@@_undecided Same. Can't live without Freezed.
@hninnwe6015
@hninnwe6015 3 жыл бұрын
I've tried isEven() of StateProvider example. I found that it changed every time not only for even.
@FunwithFlutter
@FunwithFlutter 3 жыл бұрын
It caused the build method to be called again?
@nikkigoel
@nikkigoel 3 жыл бұрын
What's the difference between : ref.watch(_counterProvider.state) and ref.watch(_counterProvider).state Which should we use? Great video by the way.
@FunwithFlutter
@FunwithFlutter 3 жыл бұрын
One of those should give a linter warning. But there are talks to change everything to a more uniform access. So future versions of Riverpod may be a bit easier in this regard
@talatkuyuk6556
@talatkuyuk6556 3 жыл бұрын
Very nice tutorial, but the second tutorial about riverpod? As you promise :) we are waiting,
@FunwithFlutter
@FunwithFlutter 3 жыл бұрын
Second one is out! And the third coming soon
@eloquentintech3246
@eloquentintech3246 3 жыл бұрын
So I have a question. I have an app that stores state across the whole app. I am using change notifier but my state refreshes across page navigation. What might be the case?
@FunwithFlutter
@FunwithFlutter 3 жыл бұрын
Not sure. I'd need a lot more to go on. But sounds like you're maybe updating the change notifier from a build method. For example calling context.read(provider).doSomething within a build
@aviatorin
@aviatorin 3 жыл бұрын
Riverpod with Statefulwidget??can u pls explain
@FunwithFlutter
@FunwithFlutter 3 жыл бұрын
You can use a Consumer inside your build method to also consume providers.
@aviatorin
@aviatorin 3 жыл бұрын
@@FunwithFlutter Thank u, what about events..such as increment or add .. which modify state, can we do it from stateful widgets
@FunwithFlutter
@FunwithFlutter 3 жыл бұрын
You can if you want to. A StatefulWidget is almost the same as a Stateless widget, it just has an extra state opject. Think of it in a different way, though. See Riverpod as a replacement for handling state through a StatefulWidget. The purpose of a StatefulWidget is to easily manage state in a widget. The purpose of a state management framework (like Riverpod, or Bloc), is to easily manage shared state, that can be used through multiple widget's, not just the single StatefulWidget.
@srjlove2102
@srjlove2102 3 жыл бұрын
Can't w8 to deep dive in river.... pod
Riverpod Tutorial 02 - Reading providers best practices
20:06
Fun with Flutter
Рет қаралды 11 М.
State Management Like A Pro - Flutter Riverpod
10:30
Robert Brunhage
Рет қаралды 76 М.
Alex hid in the closet #shorts
00:14
Mihdens
Рет қаралды 17 МЛН
Smart Sigma Kid #funny #sigma #comedy
00:40
CRAZY GREAPA
Рет қаралды 32 МЛН
I'm Excited To see If Kelly Can Meet This Challenge!
00:16
Mini Katana
Рет қаралды 28 МЛН
Riverpod Simplified | Easy State Management
14:17
Tadas Petra
Рет қаралды 43 М.
Flutter State Management with Riverpod: The Essential Guide
28:38
Andrea Bizzotto
Рет қаралды 26 М.
Learn Flutter Hooks and Maximize Your Code Reuse
10:36
Robert Brunhage
Рет қаралды 61 М.
Flutter Riverpod State Management  (With Remi Rousselet)
55:19
HeyFlutter․com
Рет қаралды 11 М.
35 Flutter Tips That Will Change Your Life
10:53
Flutter Mapp
Рет қаралды 298 М.
Riverpod or Bloc? Which One is Better?
3:44
Flutter Guys
Рет қаралды 40 М.
Alex hid in the closet #shorts
00:14
Mihdens
Рет қаралды 17 МЛН