Search code examples
flutterlayout

Flutter Row Layout (the heighest child wins)


I want to layout a row in flutter with dynamic height items inside the row.

example:

there 2 widgets inside the row (A and B).

Widget A is a small content filled Widget (height 100px).
The height of B is bigger (eg.. 500px.)

the row should now have the height of the biggest child (B).

How can i say that child A autosize to 500px?

I know ... i can wrap the row into a SizedBox with 500px an set the crossAxisAlignment of the row to stretch... but that is not what I want ...

Is there a way to auto size all childs inside of a row to the heightest ?


Solution

  • You can use IntrinsicHeight widget like so with row's crossAxisAlignment set to CrossAxisAlignment.stretch.

    IntrinsicHeight(
      child: Row(
        crossAxisAlignment: CrossAxisAlignment.stretch,
        children: [
          WidgetA(),
          WidgetB(),
        ],
      ),
    )