Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flutter column auto height by parent row

I try use Column auto height but still not working.

Example

  • Card

    • Row

      • Expanded(flex:4)

        • NetworkImage (this image has height 120)
      • Expanded(flex: 4)

        • Container
          • Column (this is column what I need)

So I found solution that I have to use Expanded widget so I tried it and got exception

  • Card

    • Row

      • Expanded(flex: 4)

        • NetworkImage (this image has height 120)
      • Expanded(flex: 4)

        • Container
          • Expanded
            • Column (this is column what I need)

Expanded widgets must be placed directly inside Flex widgets. I/flutter (14383): Expanded(no depth, flex: 1, dirty) has a Flex ancestor, but there are other widgets between them: I/flutter (14383): - Expanded(flex: 4) (this is a different Expanded than the one with the problem) I/flutter (14383): These widgets cannot come between a Expanded and its Flex.

Thanks for help.

like image 657
Petr Klein Avatar asked Jun 14 '18 12:06

Petr Klein


1 Answers

That should be because of the fact that you are adding one of those Expanded widgets to a Container.

An Expanded widget must be a descendant of a Row, Column, or Flex, and the path from the Expanded widget to its enclosing Row, Column, or Flex must contain only StatelessWidgets or StatefulWidgets (not other kinds of widgets, like RenderObjectWidgets).

Replacing the container with a Column should fix it.

like image 194
Siavash Avatar answered Oct 11 '22 05:10

Siavash