Flutter column auto height by parent row

删除回忆录丶 提交于 2019-12-11 07:29:54

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/50857403/flutter-column-auto-height-by-parent-row

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!