How to set the initial value of Flutter autocomplete_textfield

寵の児 提交于 2019-12-13 04:16:25

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!