我是flutter的新手,我想在flutter的Textformfield中创建一个可搜索的下拉菜单。如下图——
我想在左侧显示图标,在右侧显示文本,如图所示。当我单击任何建议项目时,它应该进入 textformfield。数据将从服务器加载。我将从服务器 api 调用接收 json 格式的图标和文本。请为我提供任何解决方案来实现这一目标。
Container(
child: SearchableDropdown(
value: _bankChoose,
isCaseSensitiveSearch: true,
items: bankDataList != null
? bankDataList.map<
DropdownMenuItem<
BankListDataModel>>(
(BankListDataModel value) {
return DropdownMenuItem(
value: value,
child: Row(
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
new CircleAvatar(
backgroundImage:
new NetworkImage(
value.bank_logo),
backgroundColor: Colors.white,
radius: 12,
),
// Icon(valueItem.bank_logo),
SizedBox(
width: 15,
),
Text(value.bank_name, style: TextStyle(fontSize: 14, fontFamily: "verdana_regular",
color: text_gray_color, fontWeight: FontWeight.w500),),
],
),
);
}).toList()
: null,
isExpanded: true,
hint: "Select one",
searchHint: "Select one",
onChanged: (BankListDataModel newSelectedBank) {
setState(() {
_onDropDownItemSelected(newSelectedBank);
print("selected Bank name " + _bankChoose.bank_name);
});
},
),
),