Limit the size of showDialog barrier and content

273 views Asked by At

I'm trying to clip or limit the size of the showDialog barrier so it can be contained in another widget.

I tried using LayoutBuilder inside the showDialog to get the constraints, but it isnt working.

I'm on flutter 2.2 WEB

I also tried setting a globalkey on the widget thats has the size I don't want to overflow and getting the RenderBox size but the size returnet is the final size of my browser.

enter image description here enter image description here

1

There are 1 answers

0
flutter_bee On

try adding a column inside the content in the dialog and set the mainAxisSize to min

showDialog(
        context: context,
        builder: (BuildContext context) {
          return AlertDialog(
            title: new Text("Smaller Dialog"),
            content: Column(
                mainAxisSize: MainAxisSize.min,
                children: [
                   //your code here
                ]
                ),
              );
            });