flutter - 当我将 id 作为 DropdownMenuItem | 中的值访问时,可搜索的下拉搜索不起作用 扑
问题描述
我正在使用 searchable_dropdown: ^1.1.3 包来搜索下拉菜单中的元素,当我使用区(给出区名称)作为 DropdownMenuItem 中的值时,它可以正常工作。但问题是当用户选择区时,我希望该值作为 DistrictId。但是当我将 DistrictId 作为值时,搜索不起作用。下面是我的代码。
Center(
child: SearchableDropdown.single(
isExpanded: true,
value: selectedName,
hint: "Select one",
searchHint: "Select one",
// hint: Text('Select Name'),
items: districtList.map(
(list) {
return DropdownMenuItem(
child: Text(list['district']),
value: list['districtId'],
);
},
).toList(),
onChanged: (value) {
setState(() {
selectedDistrict = value;
print(selectedDistrict );
});
},
),
),
解决方案
推荐阅读
- list - 在列表中的元素之间添加零?
- python - 在 Linux Mint 中使用启动器和基本代码启动 Jupyter Notebook
- windows - 如何诊断“随机”winsock 故障
- javascript - 使用异步数据调用值的 Google Chart DataView 计算列
- ios - iOS 通用链接:我是否必须发布我的应用才能测试通用链接?
- java - 使用 glide 从服务器加载图像
- reactjs - 为什么 useEffect 不能在 window.location.pathname 更改时运行?
- postgresql - Postgres 使用 Bitmap Index Scan 而不是普通的 Index Scan
- ansible-template - 使用 regex_search 从标准输出注册变量
- node.js - Mongoose (MongoDB) - 关系不会停止删除