Flutter TextFormField onChanged event
Solution 1
Are you wrapping TextFormField
in a FormField
widget? If not, I suggest to use just TextField
which has an onChange
property
Edit: To set an initial value you can add a TextEditingController
and asign it to the TextFormField
TextEditingController _controller = TextEditingController();
then in initState() you can do
_controller.text = 'Initial Value'
Solution 2
Lucky for us the onChanged option in the TextFormField is already available. If you update flutter and doesn't work just go to the text_form_field.dart file by clicking on the Widget TextFormField + command/control and modify the text with code in the link: text_form_field.dart
Comments
-
SHASHI KUMAR S 11 months
I want to build autocomplete using
TextFormField
, I don't know how to create OnChanged event forTextFormField
My requirement is there will be text field with some text, if user edits that text, textfield should behave like auto suggest. -
SHASHI KUMAR S about 5 yearsyes I am wrapping
TextFormField
in aFormField
widget. Is it possible to setTextField
value through code likeinitialValue
ofTextFormField
? -
Sebastian about 5 years@SHASHIKUMARS I've just updated my answer. Let me know if it helps
-
Sebastian about 5 years@SHASHIKUMARS you can check this question out stackoverflow.com/questions/48870082/… it may help you