Тёмный

Flutter StateNotifier + Riverpod Tutorial - Immutable State Management 

Reso Coder
Подписаться 113 тыс.
Просмотров 31 тыс.
50% 1

📗 Learn from the written tutorial 👇👇
resocoder.com/...
📧 Get Flutter news 📰 and resources:
👉 flutter.education
👨‍💻 Do you write good code? Find out now!
resocoder.com/...
Riverpod is not only about providing objects around the app. It comes bundled and closely integrated with StateNotifier which is a state management class. It resembles the default Flutter's ValueNotifier or even Cubit from the Bloc package without the underlying streams. This kind of immutable state management is great for keeping unpleasant surprises at bay.
Go to my website for more information, code examples, and articles:
● resocoder.com
Follow me on social media:
● / resocoder
● / resocoder
● / resocoder

Опубликовано:

 

1 окт 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 98   
@hirunguyen4522
@hirunguyen4522 3 года назад
your tutorial confused me when i started Flutter a year ago, but now they are the most helpful. Your videos are the best for people that already have a little experience and above
@kashtonnathanael2825
@kashtonnathanael2825 3 года назад
I know Im asking randomly but does anyone know of a tool to log back into an Instagram account?? I was stupid lost my account password. I appreciate any assistance you can give me
@UsamaKarim
@UsamaKarim 2 года назад
Same happened with me
@luisangelaguilarrojas1551
@luisangelaguilarrojas1551 3 года назад
Thanks a lot Reso, thanks to you and your Flutter DDD course I got a job.
@ResoCoder
@ResoCoder 3 года назад
Great to hear that! My pleasure!
@ФирузВорисов
@ФирузВорисов 3 года назад
Congratulate to you. I got a job too )
@siddharthbisht8522
@siddharthbisht8522 2 года назад
Why are you providing FakeWeatherRepository to weatherNotifierProvider when WeatherNotifier can just import it inside its code?
@vaibhavdangayachvd
@vaibhavdangayachvd 3 года назад
I still feel more comfortable using cubit + injectible
@ResoCoder
@ResoCoder 3 года назад
Everyone has their preferences and these two packages are great and stable pieces of code too!
@frederickmfinanga2037
@frederickmfinanga2037 3 года назад
Man like Reso! Thank you! We needed this tut!
@paulboamah
@paulboamah 3 года назад
Thanks so much, I've suffering with this for a long time
@aaklii
@aaklii 3 года назад
Mat, do u think Riverpod should replace BLoc in DDD?
@LUKAS3675
@LUKAS3675 3 года назад
I smell a `freezed` implementation on top of this coming up next
@francescofreddi4374
@francescofreddi4374 3 года назад
**state chenge name, in last flutter_riverpod update; i think So... what i need to watch about weatherNotifierProvider... mmmmmmmmmmm There is an exception on gitHub final project, now with flutter_riverpod: ^0.14.0+3: +Exception has occurred.NoSuchMethodError (NoSuchMethodError: Class 'WeatherInitial' has no instance method 'getWeather'. Receiver: Instance of 'WeatherInitial' Tried calling: getWeather("london"))
@JETLAI123
@JETLAI123 3 года назад
Thank you and hope the next video would talk about the States_rebuilder, it's now immutable and super clean syntax.
@urklegizmo
@urklegizmo 3 года назад
for anyone getting errors with the state notifier provider in the search page, make the changes below: watch(weatherNotifierProvider.state) → watch(weatherNotifierProvider) and watch(weatherNotifierProvider) → watch(weatherNotifierProvider.notifier) if anyone knows why this works, please tell me. I assume its just a syntax change but I have no idea 😅
@jimaustin3608
@jimaustin3608 3 года назад
23:35 Syntax for snackbar call has changed: flutter.dev/docs/release/breaking-changes/scaffold-messenger
@osmncnn
@osmncnn 2 года назад
This package old so we can't reach state property like you . So can you upload new video about riverpod please :D
@frederickmfinanga2037
@frederickmfinanga2037 3 года назад
I have small question, how do we use useProvider inside life cycle hooks such as didChangeAppLifecycleState? since it's outside the widget build context?
@mustafaahmedraza5294
@mustafaahmedraza5294 Год назад
anyone can explain why he is not using futureprovider for weather network call instead of all boiler stuff done with statenotifer ?
@farhanfarooqui
@farhanfarooqui 2 года назад
Can you give an update on the StateNotifierStateProvider? I can't find it on the latest version. I
@Domasch92
@Domasch92 3 года назад
Is there any chance you will make an discord channel for your community? That would be awesome
@poomchantarapornrat5685
@poomchantarapornrat5685 3 года назад
Hope you share some thoughts about GetX
@programan6391
@programan6391 3 года назад
Please, a tutorial about migration Bloc v6 > v6.1.0
@alvin3171997
@alvin3171997 3 года назад
Amazing! Would really love to see how to add 'Dartz Either' into this implementation.
@ultrahle
@ultrahle 3 года назад
me too
@TechWithDnes
@TechWithDnes 3 года назад
This is what I'm looking for 😁
@thiagocarvalho3430
@thiagocarvalho3430 3 года назад
Why don't you use equatable package?
@aminabudahab
@aminabudahab 3 года назад
Hi, I was wondering .. do you do projects?
@Ben-wf5ji
@Ben-wf5ji 3 года назад
How to check net connectivity in riverpod?
@jimaustin3608
@jimaustin3608 3 года назад
The riverpod ^0.13.0 to ^0.14.0 update was more complex than my post (below) indicated. See riverpod.dev/docs/migration/0.13.0_to_0.14.0/ If you use the 0.12.1 version (like Matt), his code should work … although I had some weird errors in going back.
@h3w45
@h3w45 3 года назад
Thank you for covering this.
@thomasmabika7291
@thomasmabika7291 3 года назад
it's interesting how riverpod is very similar to cubit. With cubit we could use the package bloc_test which makes testing really easy. What about riverpod? how would you go about testing your code here?
@sambaotaku
@sambaotaku 3 года назад
If I have 2 textformfields and a button to submit, like a LoginPage, where I save the 2 textformdfield values to submit? in variables on the StatelessWidget or in the StateNotifier? I have a more complex case, where I have 3 dropdowns (Country, State, and City) and if I change country the state and city dropdowns are reset, and I dont know the correct way to do this with this approach.
@meshkatshadik
@meshkatshadik 3 года назад
Hey brother, when I was implementing statenotifier today. userStateNotifierProvider (i.e. statenotifier variable) is with 2 arguments instead of 1. Then another problem is I can't watch by (userStateNotifierProvider.state) there is no scene of state. I had to install the old version of riverpod to work!
@nicolasfourcade5637
@nicolasfourcade5637 3 года назад
Hello, in Cubit there is buildWhen to determine when to rebuild based on the change of a state property. In Riverpod we have that possibility? I know that you can create a Provider that reacts to the change of a property of a StateNotifierProvider, and work with the new Provider. But it seems too twisted to be real. From already thank you very much for your time.
@TecnoRero
@TecnoRero 3 года назад
Your channel is SO helpful, I'm learning tons of good practices and ways to improve my horrible Statefulwidgets-state-management app. I already read DDD book so now I plan to apply these concepts and your DDD course to my app!
@НаильГилазиев
@НаильГилазиев 3 года назад
Please help to figure out how to use Navigator 2.0 (web) + riverpod + state_notifier. There is no any good practice example on the internet :(
@LastKing25195
@LastKing25195 3 года назад
Hi thank you a lot for this tutorial. I used this tutorial to get Data from the FireStore. But I was wondering, why the Provider doesn't cache the results, like it did in the 40 minutes Riverpod tutorial. Do you have any recommendations on how I would be able to achieve, that? Cause in my UseCase the user can change the state of the widget with a buttonclick and I would like to prevent getting the data from the Store for each click.
@sanjibdutta9270
@sanjibdutta9270 3 года назад
Great tutorial as always. Till date I use bloc and comfortable with that. But riverpod looks better. I just started a new project in flutter, it will be long run project. Can you please tell me, whether should I use riverpod or bloc is also fine. Your suggestion means a lot to me..🙏
@ResoCoder
@ResoCoder 3 года назад
The original Bloc with events is great if you need event sourcing. However, if you'd use Cubit anyway, you might as well use StateNotifier instead. By the way, you can also use Bloc with Riverpod. Here's a package that allows you to do that without any more work on your part: pub.dev/packages/riverbloc
@sanjibdutta9270
@sanjibdutta9270 3 года назад
@@ResoCoder great. thanks a lot 🙏
@abbasalhashim3716
@abbasalhashim3716 3 года назад
Great tutorials! Can you make a complete login system using phone auth?
@abbasalhashim3716
@abbasalhashim3716 3 года назад
I've looked many articles. but they seem to be not following the best practices which is using BLoC pattern
@heshamabuzaid4293
@heshamabuzaid4293 2 года назад
thanks a lot the master of flutter.
@2yaya123
@2yaya123 3 года назад
It might be a stupid question but it looks like ChangeNotifier has less code and simpler to read. Is StateNotifier better? if so how? thank you very much
@santoshkawale21
@santoshkawale21 3 года назад
Thanks for great tutorial....new version released with breaking changes....are there any chances of updated tuturial??
@sharukhrahman7925
@sharukhrahman7925 3 года назад
Hey when to use bloc and when to use riverpod.. any pointers would be helpful!.. BTW, only your channel has the best content for flutter keep it up
@terblanchedaniel5241
@terblanchedaniel5241 3 года назад
Why do you not have a BILLION subscribers yet? Quality content man. Thanks a lot.
@delmanali4863
@delmanali4863 2 года назад
Please do more app on riverpod
@georgevincent4447
@georgevincent4447 3 года назад
How would you modify the code if I want to get the weather of "some" location on the load itself? Since it is not recommended to use context.read() in build methods, I am really not sure how one would do that.
@KuroManX
@KuroManX 2 года назад
This tutorial being outdated helped me a lot to improve my skills. I learned so much fixing the old code issues to the new version.
@techzone2009
@techzone2009 3 года назад
Please continue this series
@Pandazaar
@Pandazaar 3 года назад
Hey man, this is just what I needed! Thanks a lot. Could you maybe explain riverpod with hooks? Or just like the most common hooks, there aren't many examples on the internet and it leaves me confused quite often. For instance, I thought we could useContext() inside an onTap function when we get it out of the build method, but it doesn't work there. So when would useContext be useful? Also I'm kinda struggling with the idea of useEffect. Anyways, thanks for this. Hope to see more riverpod stuff! :D
@listendream2792
@listendream2792 2 года назад
Thank you so much for this video. You are my best flutter teacher in youtube.
@iqboladahamjonov9835
@iqboladahamjonov9835 3 года назад
Can you please make a video about GetX state management, what are your thoughts about it?
@wildcatmunni
@wildcatmunni 3 года назад
Really appreciate your work..Superb work.. Got what i needed.
@christianeichmueller8637
@christianeichmueller8637 3 года назад
Really awesome video about statenotifier plus riverpod. I would be super interested which shortcut you used at 19:36 . This one looks really super useful
@nileshbhakre7050
@nileshbhakre7050 3 года назад
as a bloc lover, i want riverpod to become more robust state management package,
@dhruvraval9103
@dhruvraval9103 3 года назад
Which video editor you used for creating video and for screen recorder?
@albanr8028
@albanr8028 3 года назад
Thank you so much ! This tutorial is awesome !!
@arnaualloza7574
@arnaualloza7574 3 года назад
What is better? Flutter bloc or riverpod?
@ashoms0a
@ashoms0a 3 года назад
Thanks a million for the super clean explanation! awesome as always
@muhammadtalha5665
@muhammadtalha5665 3 года назад
made my night :) i can focus better at night.
@diogoribeiro1543
@diogoribeiro1543 3 года назад
For those using Equatable, can you confirm which aproach is the best one? EXAMPLE 1: Using EquatableMixin in each implementation... class WeatherLoaded extends WeatherState with EquatableMixin { final Weather weather; const WeatherLoaded(this.weather); @override List get props => [weather]; } EXAMPLE 2: ... Or extends Equatable in the abstract class in order to our implementations follow the contract? abstract class WeatherState extends Equatable { const WeatherState(); } class WeatherLoaded extends WeatherState { final Weather weather; const WeatherLoaded(this.weather); @override List get props => [weather]; }
@ResoCoder
@ResoCoder 3 года назад
I'd go with the second approach if you want to use Equatable.
@diogoribeiro1543
@diogoribeiro1543 3 года назад
@@ResoCoder thank you! :)
@tintin537
@tintin537 3 года назад
If you want to create a large project do you prefer Bloc or Riverpod?
@dimitristotsios2292
@dimitristotsios2292 3 года назад
Whatever you re comfortable with. In this example we see similar technique to state emition of bloc compined with Riverpod providers.
@tintin537
@tintin537 3 года назад
@@dimitristotsios2292 yes I saw that too, I just wanted to see if Matt wants to change strategies when he saw this Riverpod. And if he does I wanted to see why. Because if he changes there is a good reason for it. He is a good and precise programmer.
@dimitristotsios2292
@dimitristotsios2292 3 года назад
Amir Ebrahimi Riverpod is a hot topic this time, there are several solutions one can choose for state management. It has poor documentation and confusing for the newcomers, but tuts like this one reveals its power and elegance. I have also took a view of Binder which is somehow similar to Riverpod both are implemented by very active programmers and look very promising.
@tintin537
@tintin537 3 года назад
@@dimitristotsios2292 Agreed. I personally use Bloc and I'm comfortable with it I think it is a good approach.
@ResoCoder
@ResoCoder 3 года назад
New projects I create right now use Riverpod + StateNotifier because I usually use Bloc only with the Cubit classes anyway (I don't need event sourcing). It's more about Provider vs Riverpod than about Bloc vs Riverpod though. You can use Bloc/Cubit with Riverpod too - either create and maintain your own BlocProvider class or use a package such as this one: pub.dev/packages/riverbloc
@Gvfm1596
@Gvfm1596 3 года назад
Hope you share some thoughts about GetX
@dennisbarzanoff9025
@dennisbarzanoff9025 3 года назад
These proxy providers started being really annoying in my projects, should I swap for Riverpod?
@matthieuregnauld9648
@matthieuregnauld9648 3 года назад
Why is it getting annoying? I'm curious, since I plan to use them in my project.
@dennisbarzanoff9025
@dennisbarzanoff9025 3 года назад
@@matthieuregnauld9648 It's fine, but it gets really messy when you have tons of providers and I don't think it makes sense to seep them in the context anyway. They are pretty mainstream though
@banglafactsteller6780
@banglafactsteller6780 3 года назад
i try use freezed but failed . plz give me a hint how to use freezed for this Tutoria
@Mark-og2cu
@Mark-og2cu 3 года назад
Did you watch his video dedicated to freezed? What's not working?
@Add0w
@Add0w 3 года назад
this is bloc like syntax
@aliakkawi4759
@aliakkawi4759 3 года назад
Great explanation and examples, thanks a lot. i Know it is a silly question but which approach is better in your opinion, Riverpod with State notifier or Cubit. thanks
@ResoCoder
@ResoCoder 3 года назад
I won't say what's better but rather what I use in my new projects - Riverpod with StateNotifier. But then again, you can use Bloc/Cubit and Riverpod too! pub.dev/packages/riverbloc
@aliakkawi4759
@aliakkawi4759 3 года назад
@@ResoCoder thanks for your respond, i guess I asked the question the wrong way. I meant to ask about using Riverpod with State notifier VS using Bloc and Cubit without Riverpod
@kind8735
@kind8735 3 года назад
@@ResoCoder why do you choose riverpod for your next project instead of riverbloc or flutter_bloc? It seems their usage are very similar. Maybe you could dissect them by performance, memory usage, best practices, etc?
@faisalmushtaq2287
@faisalmushtaq2287 3 года назад
thanks alot for this
@jimaustin3608
@jimaustin3608 3 года назад
From pub.dev flutter_riverpod ChangeLog 0.14.0: BREAKINGflutter_ CHANGE The syntax for using StateNotifierProvider was updated. Appears to me that .state is no longer needed, or allowed.
@chanky262
@chanky262 3 года назад
I Just learned Cubit and im quit confused. It is pretty similar so i will ask here. Can i have multiple cubids/notifiers in my app? If i created cupid for auth, can I create next cubid for fetching data from database or i should look for something else.
@thomasmabika7291
@thomasmabika7291 3 года назад
of course you can. You can have AuthCubit, WeatherCubit, UserCubit etc.
@ResoCoder
@ResoCoder 3 года назад
You actually *should* have multiple StateNotifiers/Cubits. And you're right, Cubit and StateNotifier are very similar and my unscientific guess would be that they're the same in 99% of circumstances. The only difference is that StateNotifier is not a Stream.
@chanky262
@chanky262 3 года назад
@@ResoCoder Thanks for your reply. Now I know how to work properly with cubit/riverpod (hope so hah). Let me ask for something cuz I'm just curious. Are you english native speaker or you just learned a lot and worked in english?
Далее
Riverpod 2.0 - Complete Guide (Flutter Tutorial)
1:03:37
Просмотров 109 тыс.
Unreal Fest Seattle 2024 | Opening Session
2:01:15
Просмотров 85 тыс.
Riverpod Simplified | Easy State Management
14:17
Просмотров 44 тыс.
How to Properly Test Your Flutter App
1:09:00
Flutter Bloc & Cubit Tutorial
47:58
Просмотров 121 тыс.
State Management Like A Pro - Flutter Riverpod
10:30
Просмотров 76 тыс.
Flutter Riverpod Tutorial - The Better Provider
41:26