Petr Klein
Petr Klein

Reputation: 1033

Flutter column auto height by parent row

I try use Column auto height but still not working.

Example

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

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.

Upvotes: 6

Views: 20775

Answers (1)

Siavash
Siavash

Reputation: 3598

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.

Upvotes: 6

Related Questions