Sal*_*Sal 2 flutter flutter-layout
我正在开发 Flutter 应用程序并遇到错误Unbounded Width Constraints。这是完整的错误消息:
RenderFlex children have non-zero flex but incoming width constraints are unbounded.
When a row is in a parent that does not provide a finite width constraint, for example if it is in a
horizontal scrollable, it will try to shrink-wrap its children along the horizontal axis. Setting a
flex on a child (e.g. using Expanded) indicates that the child is to expand to fill the remaining
space in the horizontal direction.
These two directives are mutually exclusive. If a parent is to shrink-wrap its child, the child
cannot simultaneously expand to fit its parent.
Consider setting mainAxisSize to MainAxisSize.min and using FlexFit.loose fits for the flexible
children (using Flexible rather than Expanded). This will allow the flexible children to size
themselves to less than the infinite remaining space they would otherwise be forced to take, and
then will cause the RenderFlex to shrink-wrap the children rather than expanding to fit the maximum
constraints provided by the parent.
parentData: offset=Offset(0.0, 0.0) (can use size)
constraints: BoxConstraints(0.0<=w<=1298.0, 0.0<=h<=827.0)
size: MISSING
direction: vertical
mainAxisAlignment: start
mainAxisSize: max
crossAxisAlignment: center
verticalDirection: down
Run Code Online (Sandbox Code Playgroud)
这是损坏的代码:
Column(
children: [
Container(
child: Row(
children: [
Column(children: formFieldGroupChildren),
],
),
),
],
);
Run Code Online (Sandbox Code Playgroud)
这是一个有效的例子:
Column(
children: [
Container(
child: Column(children: formFieldGroupChildren),
)
],
);
Run Code Online (Sandbox Code Playgroud)
看起来Row小部件不受限制,但我不确定如何克服错误。在包装上设置宽度和高度限制Container似乎也没有帮助。我需要在其右侧放置另一个元素,Column(children: formFieldGroupChildren)这就是我需要该Row元素的原因,但似乎我在实现中缺少了一些东西。关于造成这种情况的原因有什么想法吗?感谢先进!
尝试添加 IntrinsicHeight 以适合 formFieldGroupChildren 中最高的。
Column(
children: [
Container(
child: IntrinsicHeight(
child: Row(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Expanded(child: Column(children: formFieldGroupChildren)),
],
),
),
),
],
);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2011 次 |
| 最近记录: |