showDialog关于在flutter内部调用的方法有错误吗? [英] showDialog has an error regarding method called inside it in flutter?

查看:231
本文介绍了showDialog关于在flutter内部调用的方法有错误吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用showDialog方法,并且该对话框在showDialog内部被调用(它将出现在onTap中). showDialogproDialog上的红色快速提示行

I am using showDialog method and that dialog is called inside showDialog (which will appear onTap). showDialog has red quickly lines on proDialog with some statement

这是我正在使用的Dialog小部件:

This is the Dialog widget I am using :

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

This is where I am calling and getting some error on proDialog

推荐答案

您应将对话框作为构建器传递或致电构建器:

You should pass the dialog as the builder or call the builder:

showDialog(
  context: context,
  builder: proDialog,
);

showDialog(
    context: context,
    builder: (BuildContext context) => proDialog(context),
);

这篇关于showDialog关于在flutter内部调用的方法有错误吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆