我遇到错误,尝试编辑TextField一段时间,它显示红色屏幕,然后一切恢复正常:
I / flutter(30508):引发了另一个异常:构建函数返回null。
我的代码像这样:
void _showDialog(BuildContext context, result, int decision) {
// flutter defined function
showDialog(
context: context,
builder: (BuildContext context) {
// return object of type Dialog
return AlertDialog(
title: Text("Tutar Giriniz"),
content: TextField(
controller: _textFieldController,
keyboardType: TextInputType.number,
),
actions: <Widget>[
// usually buttons at the bottom of the dialog
new FlatButton(
child: new Text("Kapat"),
onPressed: () {
result["amount"] = _textFieldController.text;
result['decision'] = decision;
Navigator.of(context).pop();
},
),
],
);
});
}```
答案 0 :(得分:0)
我找到了解决方案。关于类的构建功能。我那里有一个if条件,我用空容器写了else条件。
if (snapshot.connectionState == ConnectionState.done) {
return FittedBox(
fit: BoxFit.fitWidth,
child: DataTable(
columns: [
DataColumn(label: Text('Maç')),
DataColumn(label: Text('Ev Sahibi')),
DataColumn(label: Text('Beraberlik')),
DataColumn(label: Text('Deplasman')),
],
rows: List.generate(matches.length,
(index) => _getDataRow(matches[index], context)),
));
} else {
return Container();
}```