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

Clearing the form field #16

Open
Koushikphy opened this issue Nov 16, 2021 · 3 comments
Open

Clearing the form field #16

Koushikphy opened this issue Nov 16, 2021 · 3 comments

Comments

@Koushikphy
Copy link

How do you clear the select form field. I'm using a TextEditingController and calling clear method to it doesn't clear the form field

@ehusmann
Copy link

ehusmann commented Mar 2, 2022

It seems like the field does not listen correctly to the controller. When you try the opposite, setting a value through the controller, it also does not work. It will change the selected item in the drop down list, but it does not change the value displayed in the field. In other words, it is not possible right now to change the value through programmatic action.

@hslbetto
Copy link
Member

Sorry, I don't know if I understood fine.
Check the example app inside this package, there I use controller clear() and it work fine.
https://github.com/m3uzz/select_form_field/blob/master/example/lib/main.dart

@ehusmann
Copy link

ehusmann commented Apr 6, 2022

I have just tested that and it does indeed work (both with the clearing of the field, as well as setting it programmatically). However, it works when you put the element inside of a stateful widget and make the change in the controller in the setState method. That seems to me like a wrong thing to do. My expectation is that when I change the value in the controller, it automatically updates the input element (as it does in normal TextFields for example).

In other words, I would prefer to see a solution where the select form field implements the listening to the controller and updating the state, in stead of me having to do that. But, having said that, it does work like this.

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