我有以下 DropdownButton 小部件:
Center(
child: DropdownButton<dynamic>(
value: selectedTipoInterno,
items: dataTiposInt.map(
(list) {
return DropdownMenuItem(
child: Text(list['tipo_int']),
value: list['id'],
);
},
).toList(),
onChanged: (value) {
setState(() {});
},
),
)
這里有 dataTiposInt 的值:
[{"id":"1","tipo_int":"Administrador"},{"id":"2","tipo_int":"Editor"},{"id":"3","tipo_int":"Supervisor"},{"id":"4","tipo_int":"Analista"},{"id":"5","tipo_int":"Colaborador"}]
我收到以下錯誤輸出:
There should be exactly one item with [DropdownButton]'s value: Administrador.
Either zero or 2 or more [DropdownMenuItem]s were detected with the same value
'package:flutter/src/material/dropdown.dart':
Failed assertion: line 894 pos 15: 'items == null || items.isEmpty || value == null ||
items.where((DropdownMenuItem<T> item) {
return item.value == value;
}).length == 1'
uj5u.com熱心網友回復:
我希望我能做一點評論,但還沒有足夠的聲譽。
datatiposInt你的代碼中的值是這樣寫的嗎?還是生成的?如果是后者,那么查看該代碼也可能會有所幫助。
另外,我猜你selectedTipoInterno的不是字串型別,所以我想知道這是否會引發下拉選單
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/420302.html
標籤:
下一篇:模板類的繼承
