0

I want to know how can I find a widget's default size to set it as constraints: minHeight or constraints: maxHeight properties?

For example if I have this widget:

      Expanded(
        child: Column(
          children: [
            // right menu 1
            Expanded(
              child: Padding(
                padding: const EdgeInsets.all(8.0),
                child: Container(
                  constraints: BoxConstraints(
                    maxHeight: constraints.maxHeight - 16,
                    minHeight: 100,
                  ),
                  decoration: BoxDecoration(
                    borderRadius: BorderRadius.circular(8),
                    color: Colors.blue[400],
                  ),
                ),
              ),
            ),
            // right menu 2
            Expanded(
              child: Padding(
                padding: const EdgeInsets.all(8.0),
                child: Container(
                  constraints: BoxConstraints(
                    maxHeight: constraints.maxHeight - 16,
                    minHeight: 100,
                  ),
                  decoration: BoxDecoration(
                    borderRadius: BorderRadius.circular(8),
                    color: Colors.red[200],
                  ),
                ),
              ),
            ),
          ],
        ),
      ),

And I want to set minHeight to the container's default height instead of hardcoded 100.

GoodMan
  • 542
  • 6
  • 19
  • 1
    (If I am not wrong)More like widget adapt the minimum size, some are needed to config, which widget you like to provide constrains, and also it is depended on parent widget. It will easy if you could provide exact widget, your snippet. Also, you can use key to get widget size – Md. Yeasin Sheikh Aug 12 '22 at 15:38
  • @YeasinSheikh: I tried to add an example. – GoodMan Aug 12 '22 at 15:48
  • what exactly do you want to achieve? what's your goal? – pskink Aug 12 '22 at 16:00
  • @pskink: My goal is locking a widget to get smaller than it's default size when the running app window size changes. – GoodMan Aug 12 '22 at 16:43

1 Answers1

0

There's a Widget for that

Have you tried LayoutBuilder?

venir
  • 1,809
  • 7
  • 19