【发布时间】:2020-12-04 04:25:08
【问题描述】:
我在更改 SearchDropdown 对象的状态时遇到了问题。如果已选择项目,则该值不会更改。如果我删除它,那么我可以改变状态。我不明白问题出在哪里。
@override
void initState() {
_dropdownPlatformReach =
buildDropdownMenuItemsPlatformReach(_platformReach);
_selectedPlatformReach = _dropdownPlatformReach[0].value;
super.initState();
}
Expanded(
child: SearchableDropdown.single(
isExpanded: true,
value: _selectedPlatformReach,
hint: " ",
items: _dropdownPlatformReach,
onChanged: (PlatformReach selectedPlatformReach) {
setState(() {
_selectedPlatformReach = selectedPlatformReach;
});
},
),
flex: 2,
),
class PlatformReach {
String name;
String hint;
PlatformReach(this.name, this.hint);
static List<PlatformReach> getPlatformReach() {
return <PlatformReach>[
PlatformReach('Jud Galati', '(RO, [Galati] County)'),
PlatformReach('Jud Braila', '(RO, [Braila] County)'),
PlatformReach('Jud Prahova', '(RO, [Ploiesti] County)'),
PlatformReach('Jud Maramures', '(RO, [Baia Mare] County)'),
];
}
}
【问题讨论】:
标签: flutter dart mobile native