-
Notifications
You must be signed in to change notification settings - Fork 219
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
VM -> widget data transfer: am I doing it right? #17
Comments
Heya @kentcb :) Great question, as always! Let me see if I can tackle these: 1The view has just been created and it needs to reflect data in the VM that has been loaded. -- In this case, I simply grab the strings I need from the store and pass it to my 2I think the second case is the tricky one! Flutter is mostly reactive, but then has these imperative bits like TextEditingControllers and Navigators and it makes working with reactive patterns like Redux a bit harder. To be honest, I'm not sure how easy it would be with any pattern given the challenge with handling the selection :) Lemme play around with a couple ideas and I'll see If I can come up with something a bit better! I can definitely understand your use case. |
Yeah, the departure from the reactive approach has bitten me with It's also interesting to note that whilst |
Hey hey -- maybe should have closed this before now, but we now have the |
Hi,
There's something I've found myself doing in each of my views, and I can't help but think it's more complicated than it should be, so I just wanted to check in to see how I should be handling this.
The scenario is simply that I want to transfer data from the VM to the view for a
TextField
that has a controller. The reasons I might need to do this include:As a simple example, imagine a login page. When login fails, the reducer resets the password back to empty (or
null
). That should of course be reflected in the view. However, I don't see a way to ensure this without manually applying the value to theTextEditingController
.Manually transferring the values isn't so bad, except that it quickly gets complicated because I need to take selection into account. Currently my helper method looks like this:
I call this at the start of my
build
method for eachTextEditingController
, passing in the value provided by the VM. It's all a bit awkward, so I feel like I'm missing something obvious here.Any thoughts?
The text was updated successfully, but these errors were encountered: