Replies: 1 comment 3 replies
-
For forms, I would recommend keeping the state local to your widgets (possibly using hooks if that's your thing). And put the state inside providers only on submit after it has been validated |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I've been using RiverPod for a while now with Flutter, but I'm not sure what the best practice is for how to use RiverPod with a complex form.
Assume that I have a complex form that mas multiple text inputs., drop down selectors and radio buttons. For this I am using a Flutter '
' widget to manager validation and save actions. I have a model class that holds the data that is used to initiate the controls and capture the save action results.Should I create a distinct RiverPod StateNotifier provider that uses the form model as its state, or should I keep the model data local to the form widget?
The downside of using a RiverPod StateProvider provider is that I have to create a 'setXXX' method in the StateNotifier' for each data entry widget n the form. That way when the form save action is called each data entry widget can call a related method in the StateNotifier to update its property into the model
Any suggestions?
Beta Was this translation helpful? Give feedback.
All reactions