简体   繁体   English

Flutter - 如何将下拉按钮内的文本字段作为值

[英]Flutter -How to make textField inside a dropdownButton as a value

I have to insert new value into dropdown by textfield For exemple I have a dropdown of much countries but not all countries.我必须通过文本字段在下拉列表中插入新值 例如,我有一个包含许多国家但不是所有国家的下拉列表。 If user have to choose her countrie And not find it he can insert her countrie by the text field如果用户必须选择她的国家而没有找到它,他可以通过文本字段插入她的国家

Always post the code that you have written, it'll be easier for whoever wants to help you.始终发布您编写的代码,任何想帮助您的人都会更容易。

Assuming you are using a list of type <String> for the dropdown button, called exampleList .假设您为下拉按钮使用类型为<String>的列表,称为exampleList The items of example list will make up your dropdown items.示例列表的项目将构成您的下拉项目。

If you wanted to add a new item to that list.如果您想向该列表添加新项目。

In your text field, on submission you can use exampleList.add(yourNewValue) to add items to your list.在您的文本字段中,提交时您可以使用exampleList.add(yourNewValue)将项目添加到您的列表中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM