1

Flutter & AlertDialog :如何将其与底部对齐?我如何制作像这张照片的 2 个警报对话框?请在这张照片上有很多。

在此处输入图像描述

showDialog(
                                context: context,
                                builder: (BuildContext context) {
                                  double width =
                                      MediaQuery.of(context).size.width;
                                  double height =
                                      MediaQuery.of(context).size.height;
                                  return AlertDialog(
                                    backgroundColor: Colors.transparent,
                                    contentPadding: EdgeInsets.zero,
                                    title: Center(
                                        child: Text("Evaluation our APP")),
                                    content: Container(

                                       // What Should I write here?

                                    )
                                },
                              );
4

2 回答 2

2

这是解决方案之一:

          showDialog(
            context: context,
            builder: (BuildContext context) {
              double width = MediaQuery.of(context).size.width;
              double height = MediaQuery.of(context).size.height;
              return AlertDialog(
                  backgroundColor: Colors.transparent,
                  contentPadding: EdgeInsets.zero,
                  elevation: 0.0,
                  // title: Center(child: Text("Evaluation our APP")),
                  content: Column(
                    mainAxisAlignment: MainAxisAlignment.end,
                    children: [
                      Container(
                        padding: const EdgeInsets.all(8.0),
                        decoration: BoxDecoration(
                            color: Colors.white,
                            borderRadius:
                                const BorderRadius.all(Radius.circular(10.0))),
                        child: Column(
                          children: [
                            Text("a"),
                            Divider(),
                            Text("b"),
                            Divider(),
                            Text("c"),
                          ],
                        ),
                      ),
                      SizedBox(
                        height: 10,
                      ),
                      Container(
                        padding: const EdgeInsets.all(8.0),
                        decoration: BoxDecoration(
                            color: Colors.white,
                            borderRadius:
                                const BorderRadius.all(Radius.circular(10.0))),
                        child: Center(child: Text("d")),
                      )
                    ],
                  ));
            },
          );
于 2020-10-12T04:42:13.697 回答
0

这是我的答案,没有创建 AlertDialog 的纯小部件:


    final content = Column(
      mainAxisAlignment: MainAxisAlignment.end,
      children: [
        Container(
          decoration: BoxDecoration(
            color: Colors.white,
            borderRadius: const BorderRadius.all(Radius.circular(10.0)),
          ),
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.stretch,
            children: [
              TextButton(onPressed: () {}, child: Text("a"),),
              Divider(height: 1,),
              TextButton(onPressed: () {}, child: Text("b"),),
              Divider(height: 1,),
              TextButton(onPressed: () {}, child: Text("c"),),
            ],
          ),
        ),
        SizedBox(
          height: 10,
        ),
        Container(
          width: double.infinity,
          decoration: BoxDecoration(
            color: Colors.white,
            borderRadius:
            const BorderRadius.all(Radius.circular(10.0)),
          ),
          child: TextButton(onPressed: () {}, child: Text("d"),),
        ),
        SizedBox(
          height: 40,
        ),
      ],
    );

    showDialog(
      context: context,
      builder: (ctx) {
        return FractionallySizedBox(
          widthFactor: 0.9,
          child: Material(
            type: MaterialType.transparency,
            child: content,
          ),
        );
      }
    );

Material由于文字绘制错误必须添加。

于 2021-06-02T10:03:30.570 回答