Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to expand container but stop on a certain size? [duplicate]

Tags:

flutter

I have a Container that should take all available space, but not more than 500 x 500.

If I put it inside of Flexible or Expanded it will grow to take all the screen. Is there in Flutter something similar to android:maxWidth?

like image 904
Vadims Savjolovs Avatar asked Dec 03 '25 00:12

Vadims Savjolovs


1 Answers

You can use BoxConstraints ,

    Container(
                constraints: BoxConstraints(
                    maxHeight: 500.0,
                    maxWidth: 500.0,
                    minHeight: 100.0,
                    minWidth: 100.0),
                child: YourChild(),

                )

More info: https://docs.flutter.io/flutter/rendering/BoxConstraints-class.html

like image 152
diegoveloper Avatar answered Dec 05 '25 16:12

diegoveloper