如何设置Flutter的初始值autocomplete_textfield [英] How to set the initial value of Flutter autocomplete_textfield

查看:725
本文介绍了如何设置Flutter的初始值autocomplete_textfield的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Flutter应用程序中,我有一个输入表单,该表单将Flutter autocomplete_textfield用于一个字段.创建新条目时,表单可以正常工作.但是,我还需要能够使用表单来编辑记录.从要编辑的记录中加载表单上的所有其他字段正在工作,我找不到如何设置autocomplete_textfield的初始值.

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

推荐答案

您可以为搜索字段创建控制器,并将其用作:
TextEditingController _controller = TextEditingController();
并在init方法中添加:
_controller.text = 'YOUR_TEXT_HERE';
也不要忘记将一个控制器添加到AutoCompleteTextField:
AutoCompleteTextField<String>( controller: _controller, )

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, )

这篇关于如何设置Flutter的初始值autocomplete_textfield的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆