Flutter 生成函数返回null
我遇到一个错误,当我试图编辑一个文本字段时,有一段时间,它显示一个红色屏幕,然后一切恢复正常: I/flatter(30508):引发了另一个异常:生成函数返回null 我的代码是smt,如下所示:Flutter 生成函数返回null,flutter,Flutter,我遇到一个错误,当我试图编辑一个文本字段时,有一段时间,它显示一个红色屏幕,然后一切恢复正常: I/flatter(30508):引发了另一个异常:生成函数返回null 我的代码是smt,如下所示: void _showDialog(BuildContext context, result, int decision) { // flutter defined function showDialog( context: context, bui
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();
},
),
],
);
});
}```
void\u showDialog(BuildContext上下文、结果、int决策){
//颤振定义函数
显示对话框(
上下文:上下文,
生成器:(BuildContext上下文){
//返回对话框类型的对象
返回警报对话框(
标题:文本(“图塔GIRINIZE”),
内容:TextField(
控制器:_textFieldController,
键盘类型:TextInputType.number,
),
行动:[
//通常是对话框底部的按钮
新扁平按钮(
儿童:新文本(“Kapat”),
已按下:(){
结果[“金额”]=\u textFieldController.text;
结果['decision']=决策;
Navigator.of(context.pop();
},
),
],
);
});
}```
我找到了解决方案。这是关于类的构建函数。我有一个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();
}```
我们能看完整的代码吗?