Skip to content
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

FormBuilderTextField initialValue not working when a controller is specified #258

Closed
awhitford opened this issue Apr 18, 2020 · 3 comments
Closed

Comments

@awhitford
Copy link
Collaborator

For a FormBuilderTextField, I noticed that the initialValue does not seem to be used when I specify a controller. I am seeing a blank text field, rather than the initial value.

@danvick
Copy link
Collaborator

danvick commented Apr 21, 2020

This is the default behavior in TextFormField in Flutter. This is because while using a controller you are supposed to specify the value within it.

In fact, there's an assertion in Flutter that doesn't allow you to specify an initialValue when the controller is set.

@awhitford
Copy link
Collaborator Author

OK, if this is expected behavior, then that's fine. I didn't see anything documented, and noticed that it wasn't working so wanted to mention it.

Note that I didn't notice an assertion if I specify both for a FormBuilderTextField. Should it?

@abgrano
Copy link

abgrano commented May 2, 2020

Use static for your variable etc. For example:

static String myText;

@danvick danvick closed this as completed in b60c345 May 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants