【发布时间】:2019-04-23 11:29:59
【问题描述】:
我有一个稍后在我的主脚手架文件中调用的小部件。此窗口小部件包含一个下拉菜单,但是,选择另一个值时,我无法更改状态。该字段未更新,我收到错误消息“错误:找不到方法:'setState'。 设置状态((){' ^^^^^^^^
我已经更新了 setState 方法并从中删除了代码,但它仍然说找不到该方法。
child: DropdownButton(
hint: Text('Medical'),
value: _selectedCustomerType,
onChanged: (newValue) {
setState(() {
_selectedCustomerType = newValue;
});
},
items: _customerType.map((cusType) {
print(cusType);
return DropdownMenuItem(
child: Text(cusType),
value: cusType,
);
}).toList(),
),
我需要能够更新值并在选择新值时显示它。
【问题讨论】:
-
添加您的完整代码
标签: drop-down-menu flutter dropdown setstate