写布局遇到了一个bug,BoxConstraints forces an infinite height
2021-12-31 14:53:54.959 23302-23398/com.example.my_fllutter_test I/flutter: 错误信息1:BoxConstraints forces an infinite height.
These invalid constraints were provided to RenderConstrainedBox's layout() function by the following function, which probably computed the invalid constraints in question:
RenderConstrainedBox.performLayout (package:flutter/src/rendering/proxy_box.dart:277:14)
The offending constraints were:
BoxConstraints(w=360.0, h=Infinity)
2021-12-31 14:53:54.960 23302-23398/com.example.my_fllutter_test I/flutter: 错误信息2:#0 BoxConstraints.debugAssertIsValid.<anonymous closure>.throwError (package:flutter/src/rendering/box.dart:517:9)
#1 BoxConstraints.debugAssertIsValid.<anonymous closure> (package:flutter/src/rendering/box.dart:561:11)
#2 BoxConstraints.debugAssertIsValid (package:flutter/src/rendering/box.dart:565:6)
#3 RenderObject.layout (package:flutter/src/rendering/object.dart:1758:24)
#4 RenderConstrainedBox.performLayout (package:flutter/src/rendering/proxy_box.dart:277:14)
#5 RenderObject.layout (package:flutter/src/rendering/object.dart:1858:7)
#6 ChildLayoutHelper.layoutChild (package:flutter/src/rendering/layout_helper.dart:56:11)
#7 RenderFlex._computeSizes (package:flutter/src/rendering/flex.dart:829:43)
#8 RenderFlex.performLayout (package:flutter/src/rendering/flex.dart:931:32)
#9 RenderObject.layout (package:flutter/src/rendering/object.dart:1858:7)
#10 MultiChildLayoutDelegate.layoutChild (package:flutter/src/rendering/custom_layout.dart
在column中某个的组件的高度想充满整个剩余的位置,但是如果你不设置高度的话就会报以上这个错误,类似下面这种,就被报错
LoadStateLayout是我自己定义的一个加载页面,这个页面需要充满底部的高度,如何实现呢,用Expanded即可。
?
使用Expanded 包围整个的子组件,就可以撑满剩下的屏幕区域了
|