问题
IN my Flutter app I have an input form that uses a Flutter autocomplete_textfield for one field. When creating new entries the form works fine. However, I need to also be able to use the form to edit records. Loading all other fields on the form from the record to be edited is working, I cannot find how to set the initial value of the autocomplete_textfield.
Sid
回答1:
You can create controller to you Search Field and use it as:TextEditingController _controller = TextEditingController();
and in init method add:_controller.text = 'YOUR_TEXT_HERE';
also dont forget to add a controller to AutoCompleteTextField:AutoCompleteTextField<String>(
controller: _controller,
)
来源:https://stackoverflow.com/questions/55092666/how-to-set-the-initial-value-of-flutter-autocomplete-textfield