Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flutter & AlertDialog : How do I align it to bottom? How I make 2 Alert Dialogs like this pictures?

Flutter & AlertDialog : How do I align it to bottom? How I make 2 Alert Dialogs like this pictures?Please have a lot at this picture.

enter image description here

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?

                                    )
                                },
                              );
like image 585
Time Flies Avatar asked Sep 03 '25 07:09

Time Flies


2 Answers

Here is one of the solutions:

          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")),
                      )
                    ],
                  ));
            },
          );
like image 187
Thắng Mai Avatar answered Sep 04 '25 21:09

Thắng Mai


here is my answer, pure widget without create 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,
          ),
        );
      }
    );

have to add Material because of text drawing error.

like image 31
Wesley Chang Avatar answered Sep 04 '25 21:09

Wesley Chang



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!