Replies: 3 comments 3 replies
-
Doing this inside It sounds like your architecture is not correct. You should have a better place for modifying this provider than doing it here. |
Beta Was this translation helpful? Give feedback.
-
I read more of your answers on uni-directional data flow and now get it. I see how it's a bad idea in build but ok in a function called on some "action" performed on a UI by a user. |
Beta Was this translation helpful? Give feedback.
-
im currently migrating my project to riverpod 1.0.0, and i used similar code with OP. my code:
my intention was, to reset the state. any suggestion for better approach on this? |
Beta Was this translation helpful? Give feedback.
-
But now I heard the state is actually just
ref.read(userProvider)
and to call methods in the StateNotifier, useref.read(userProvider.notifier)
.And to also use
watch
rather thanread
for easier debugging later.Is it safe to say, these calls should be made in the same place in the code as
setState(){}
would be?I'm having a super difficult time with the transition from login to homescreen where I'm trying to initialize the state of my user and UI based on the login data.
If possible, please make some documentation on this specific case. I have a Reddit post: https://www.reddit.com/r/flutterhelp/comments/quypl5/riverpod_when_do_you_use_provider_to_set_state/?utm_source=share&utm_medium=web2x&context=3
Beta Was this translation helpful? Give feedback.
All reactions