【发布时间】:2019-02-08 14:27:18
【问题描述】:
我从 JSON 中获取项目并在下拉列表中显示它们。当该人从下拉列表中选择一个项目时,我得到了选择,但所选项目没有改变。
例如,我们在列表中有 (tokyo, paris, new york)。默认选择是东京。当该人选择巴黎时,我明白了,但下拉列表中的选择没有改变。
这是我的代码:
new DropdownButton(
value: cities.elementAt(0),
hint: new Text("Ville"),
items: cities.map((String value) {
return new DropdownMenuItem(
value: value,
child: new Row(
children: <Widget>[
new Icon(
Icons.location_city,
color: Colors.deepOrange,
),
new Text(value)
],
),
);
}).toList(),
onChanged: (String value) {
getTravelCity(value);
},
),
当人选择一个项目时,它仍然显示默认值。
【问题讨论】:
-
我试过了,但还是有同样的问题