父行的颤振列自动高度 [英] Flutter column auto height by parent row
问题描述
我尝试使用列自动高度,但仍然无法正常工作.
I try use Column auto height but still not working.
示例
-
卡
-
行
-
展开(伸缩:4)
Expanded(flex:4)
- NetworkImage(此图像的高度为120)
展开(伸缩: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
-
卡
-
行
-
展开(伸缩:4)
Expanded(flex: 4)
- NetworkImage(此图像的高度为120)
展开(伸缩:4)
- 容器
- 展开
- 专栏(这是我需要的专栏)
- Container
- Expanded
- Column (this is column what I need)
展开的窗口小部件必须直接放在Flex窗口小部件内. I/flutter(14383):Expanded(无深度,flex:1,脏)具有Flex祖先,但它们之间还有其他小部件: I/flutter(14383):-Expanded(flex:4)(这是与出现问题的人不同的Expanded) I/flutter(14383):这些小部件不能介于Expanded及其Flex之间.
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.
感谢您的帮助.
推荐答案
那应该是因为您要将这些
Expanded
小部件之一添加到Container
的事实.That should be because of the fact that you are adding one of those
Expanded
widgets to aContainer
.扩展"窗口小部件必须是行",列"或"Flex"的后代,并且 从扩展小部件到其封闭的行,列或路径的路径 Flex必须仅包含StatelessWidgets或StatefulWidgets(不能包含其他 种类的小部件,例如RenderObjectWidgets.)
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).
用Column替换容器应对其进行修复.
Replacing the container with a Column should fix it.
这篇关于父行的颤振列自动高度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
- Expanded
- 展开