发生异常。_AssertionError ('package: flutter/src/material/dropdown.dart': 断言失败: 第 915 行 pos 15: 'items == null || items.isEmpty || value == null || items.where((DropdownMenuItem item) { return item.value == value; }).length == 1': 应该只有一个项目的 [DropdownButton] 值为:0。检测到零个或 2 个或多个 [DropdownMenuItem] 具有相同的值)
DropdownButton 的“值”应设置为“null”或为值列表中的一项。
DropdownButton(
value: null,
isDense: true,
onChanged: (String newValue) {
// somehow set here selected 'value' above whith
// newValue
// via setState or reactive.
},
items: ['yellow', 'brown', 'silver'].map((String value) {
return DropdownMenuItem(
value: value,
child: Text(value),
);
}).toList(),
),
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3198 次 |
| 最近记录: |