我正在使用 showDialog
方法并且在 showDialog
中调用该对话框(它将出现在 onTap
中)。 showDialog
在 proDialog
上有红色的快速线条,带有一些语句
这是我正在使用的 Dialog
小部件:
WidgetBuilder proDialog = (BuildContext context) => Dialog(
backgroundColor: Colors.white,
child: Padding(
padding: EdgeInsets.all(17.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Padding(
padding: EdgeInsets.all(15.0),
child: Text(
'Your Profile',
style: TextStyle(
color: Colors.blue,
fontSize: 26.0,
),
),
),
Container(color: Colors.black, height: 2),
Row(mainAxisAlignment: MainAxisAlignment.start, children: <Widget>[
Padding(
padding: EdgeInsets.all(15.0),
child: Text(
'Take a Photo',
style: TextStyle(
fontSize: 26.0,
color: Colors.black,
),
),
),
]),
Container(color: Colors.black, height: 2),
SizedBox(height: 8),
RaisedButton(
padding: EdgeInsets.symmetric(horizontal: 40.0, vertical: 15.0),
textColor: Colors.white,
color: Colors.redAccent[800],
child: Text('Back', style: TextStyle(fontSize: 16)),
shape:
RoundedRectangleBorder(borderRadius: BorderRadius.circular(30.0)),
onPressed: () {
Navigator.pop(context);
},
)
],
),
),
);
这是我在 proDialog
上调用并遇到一些错误的地方
最佳答案
您应该将对话框作为构建器传递或调用构建器:
showDialog(
context: context,
builder: proDialog,
);
或
showDialog(
context: context,
builder: (BuildContext context) => proDialog(context),
);
关于flutter - showDialog 有一个关于在 flutter 中调用的方法的错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56853595/