flutter - showDialog 有一个关于在 flutter 中调用的方法的错误?

标签 flutter dart

我正在使用 showDialog 方法并且在 showDialog 中调用该对话框(它将出现在 onTap 中)。 showDialogproDialog 上有红色的快速线条,带有一些语句

这是我正在使用的 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

最佳答案

您应该将对话框作为构建器传递或调用构建器:

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

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

关于flutter - showDialog 有一个关于在 flutter 中调用的方法的错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56853595/

相关文章:

Flutter - 如何制作自定义 TabBar

flutter - 从 Visual Studio Code 运行所有 Flutter 单元测试

flutter - Flutter无法加载 Assets :但目录不存在

Flutter:使图像更小

flutter - "' _listenerAttached ': is not true"在 StatefulWidget 中布局更改后

flutter - Flutter-如何在按下“后退”按钮时重定向到特定事件?

json - Dart 解码转义的 JSON

dart - Dart 编辑器关于最终字段的错误报告不一致

flutter - 如何在 Flutter 中获得安全区域大小/填充

dart - 如何在BLoC中使用BottomNavigationBar?