RenderBox 不满足其约束的可能原因是什么?
What are possible reasons for a RenderBox not meeting its constraints?
我的 RenderBox
抛出以下断言:
The following assertion was thrown during performLayout():
RenderBox does not meet its constraints.
Constraints: BoxConstraints(w=411.4, h=411.4)
Size: Size(411.4, 411.4)
查看失败断言的实现,我发现 isSatisfiedBy
实际上应该不会失败,因为大小等于约束。
因此,我想知道是什么原因造成的。
通过调试我发现 size.height
大约是 411.42857
而 constraints.maxHeight
大约是 411.42855
。因此,我尝试降低尺寸,但奇怪的是它没有帮助。
由于大小是固定的,我通过应用 described here:
解决了这个问题
SizedBoxed(width: 411.2, height: 411.2, child: MyRenderObjectWidget())
为此,我删除了 performLayout
的覆盖并将以下内容添加到我的 RenderObject
:
@override
get sizedByParent => true;
@override
performResize() => size = constraints.smallest;
我的 RenderBox
抛出以下断言:
The following assertion was thrown during performLayout():
RenderBox does not meet its constraints.
Constraints: BoxConstraints(w=411.4, h=411.4)
Size: Size(411.4, 411.4)
查看失败断言的实现,我发现 isSatisfiedBy
实际上应该不会失败,因为大小等于约束。
因此,我想知道是什么原因造成的。
通过调试我发现 size.height
大约是 411.42857
而 constraints.maxHeight
大约是 411.42855
。因此,我尝试降低尺寸,但奇怪的是它没有帮助。
由于大小是固定的,我通过应用 described here:
解决了这个问题SizedBoxed(width: 411.2, height: 411.2, child: MyRenderObjectWidget())
为此,我删除了 performLayout
的覆盖并将以下内容添加到我的 RenderObject
:
@override
get sizedByParent => true;
@override
performResize() => size = constraints.smallest;