[英]Column's children must not contain any null values, but a null value was found at index 13. Flutter Function
[英]Flutter function error: Column's children must not contain any null values, but a null value was found at index 1
在我將下拉列表分離到 flutter 中的單獨方法后,調試器返回以下錯誤:
“列的子項不得包含任何空值,但在索引 1 處發現空值”
這是我必須使用單獨方法_actionDropdown()
的代碼:
_actionDropdown() {
DropdownButton<String>(
value: actionValue,
icon: Icon(Icons.arrow_downward),
iconSize: 24,
elevation: 16,
style: TextStyle(
color: Colors.deepPurple
),
underline: Container(
height: 2,
color: Colors.deepPurpleAccent,
),
onChanged: (String newValue) {
setState(() {
dropdownValue = newValue;
// if(dropdownValue == 'Move to...') {
// return Text('add chips for folders here');
// } else if(dropdownValue == 'Label as...') {
// return Text('add chips for labels here');
// }
});
},
items: <String>['Archive', 'Delete', 'Move To...', 'Label as...']
.map<DropdownMenuItem<String>>((String value) {
return DropdownMenuItem<String>(
value: value,
child: Text(value),
);
})
.toList(),
);
}
DropdownButton<String>
這段代碼用作列子項,但當我將分離的方法_actionDropdown
添加為子項時則_actionDropdown
。 我錯過了什么?
正如@brendan 建議您忘記添加 return 關鍵字。
_actionDropdown() {
return DropdownButton<String>( // return added here
value: actionValue,
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.