felixmccuaig / flutter-autocomplete-textfield

An autocomplete Textfield for flutter
MIT License
181 stars 131 forks source link

errorText not working #36

Closed oom- closed 5 years ago

oom- commented 5 years ago

Hi, I would want to change the message of the "errorText" value of the decoration after the "textChanged" event.

Then i have something like this:

return AutoCompleteTextField<String>(textChanged: (text) {
setState(() { if (test.length == 0) _notGood = true; else _notGood = false;},};
[...],
decoration: InputDecoration(errorText: _notGood ? 'Empty' : null,),);

The problem is that it's not working because the decoration that i pass in parameter is passed in the constructor of the AutoCompleteTextFieldState<T> class and like that its stay in "final" i can't do nothing to change it and the build method is not refreshing the TextField.

Here : https://github.com/felixlucien/flutter-autocomplete-textfield/blob/ff8d9ead701c2c5995c5d7e6417da33eb4adad28/lib/autocomplete_textfield.dart#L152

Is there any way to bypass this or for you to make a fix ?

Thank you !

Karlheinzniebuhr commented 5 years ago

Having the same issue. AutoCompleteTextField does not rebuild even though I update the errorText value in setState()

felixmccuaig commented 5 years ago

I'll look into it.

felixmccuaig commented 5 years ago

The solution that I see to this is to rebuild the whole TextField with new decoration.

felixmccuaig commented 5 years ago

This should be fixed in 1.7.3. When changing decoration etc, use updateDecoration()

Karlheinzniebuhr commented 5 years ago

This should be fixed in 1.7.3. When changing decoration etc, use updateDecoration()

I'm sorry I don't understand what you mean, I tried rebuilding the TextField and the whole AutoCompleteTextField and it didn't work for me