Moving from setState to Riverpod in Flutter Part 2
VloĆŸit
- Äas pĆidĂĄn 27. 07. 2024
- Part 2 of the Riverpod series covers few useful features of the package including:
.family modifier - send extra data to your provider
.autodispose modifier - control what happens to the state when the provider is no longer being used
reference other providers inside of providers
Using the useProvider hook to replace the Consumer widget
00:00 - intro and looking at docs
01:25 - HookWidget and useProvider hook
06:08 - creating a new FutureProvider
07:53 - Passing extra data with the family modifier
11:48 - Referencing one provider from another
13:57 - Choosing how to persist state with autoDispose
đ»Follow along here with the initial code: github.com/theflutterfactory/...
âĄConnect on Facebook: / flutterfactory
âĄConnect on Twitter: / flutterfactory
đ·Music: www.bensound.com
more riverpod i love your tutorials
Thank youâ€
great video, very clear explaining the concepts!, thanks!
Great video! Thank you a lot!
hello sir, we want more videos of hooks_riverpod with dummys api found on net...Use more of hook widgets
I'll think about it
At 1:45, there is indeed a HookStateWidget to replace a StatefulWidget that together with HookState to replace State, is nearly a drop-in replacement.
Good point. I haven't played around with flutter Hooks too much outside the context of RiverPod.
I am really interested in riverpod. I am trying to handle a registration form in a MVVM pattern with riverpod. Keep on your videos, thanks.
At 4:30, be sure to NEVER get into the habit to type "() => {}" even as a placeholder. Either "() => ()" or "() {}". The problem is that "() => {}" is legal syntax to return an empty Map from the function when it is called. Ouch!
Noticed "flutter UserList rebuilds..." each time page changes when click List, any idea why? flutter_hook issue?
Good question. There's more way to optimize the rebuilds. Wrapping the entire UserList widget (not just the return value) would be one way to prevent that UserList from rebuilding until the list is updated
@@TheFlutterFactory any gist sample?