[英]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.