【发布时间】:2022-07-19 22:59:48
【问题描述】:
我的无状态类包含带有 4 个选项卡的表单,其中一个选项卡包含 3 个下拉列表,用于为国家/地区选择地址,并根据选择的值,我希望第二个下拉列表(用于城市)查看其项目。 下拉列表的所有项目都来自本地 sqlite 数据库。 问题是第二个下拉菜单没有查看其项目,但是当我使用调试器时,我发现列表成功来自数据库,但无状态类上的列表值更新没有发生。 有什么办法解决吗??
DropdownButtonFormField<Region>(
decoration: InputDecoration(
isDense: true,
floatingLabelBehavior:
FloatingLabelBehavior.auto,
labelStyle: TextStyle(fontSize: 22),
contentPadding:
EdgeInsets.symmetric(vertical: 9),
),
value: regionList.isEmpty
? region
: helRegion.getReg(
user.regionAdresse, regionList),
//icon: Icon(Icons.arrow_downward),
iconSize: 24,
elevation: 16,
onChanged: (selectedRegion) {
onRegionSelected(context, user,
region, province, provinceList, selectedRegion);
},
items: regionList
.map((project) => DropdownMenuItem(
child: Text(project.Name),
value: project,
))
【问题讨论】:
-
欢迎来到 SO!请问edit你的问题并复制粘贴
onRegionSelected函数吗?