-
Notifications
You must be signed in to change notification settings - Fork 101
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
Can't get text field to update on rebuild of form #81
Comments
I found the problem. I am now using a controller and it works. |
what's the purpose of using TextEditingController when we should pass value by initialValue ? |
Initial value can only be set once it would appear. I wanted to be able to update the displayed value on the fly if it changed by some external operation. |
I know what you mean, I had very similar situation. Data is loaded from the storage, and date field is updated some milliseconds after UI widget is initialized. So I ended up with a code like this: in widget:
in widget state:
EDIT: this above is actually bad idea what is required to do: |
I have a stateful widget that builds and displays a Form that contains several DateTimeField widgets. The first time the form is built the initialValue that I specify is correctly set for each DateTimeField. However, when the build method is called again (because one or more of the time values has changed externally) the new initialValue is not shown - it keeps what's there. It's as if the initialValue is being ignored totally. I suspect this is not a bug but a problem with the way I'm using the DateTimeField widget.
Here's a snippet from the build method where one of the DateTimeFields is created:
The text was updated successfully, but these errors were encountered: