当前位置:   article > 正文

Flutter Column 子组件高度充满(BoxConstraints forces an infinite height)_boxconstraints forces an infinite height.

boxconstraints forces an infinite height.

写布局遇到了一个bug,BoxConstraints forces an infinite height

  1. 2021-12-31 14:53:54.959 23302-23398/com.example.my_fllutter_test I/flutter: 错误信息1:BoxConstraints forces an infinite height.
  2. These invalid constraints were provided to RenderConstrainedBox's layout() function by the following function, which probably computed the invalid constraints in question:
  3. RenderConstrainedBox.performLayout (package:flutter/src/rendering/proxy_box.dart:277:14)
  4. The offending constraints were:
  5. BoxConstraints(w=360.0, h=Infinity)
  6. 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)
  7. #1 BoxConstraints.debugAssertIsValid.<anonymous closure> (package:flutter/src/rendering/box.dart:561:11)
  8. #2 BoxConstraints.debugAssertIsValid (package:flutter/src/rendering/box.dart:565:6)
  9. #3 RenderObject.layout (package:flutter/src/rendering/object.dart:1758:24)
  10. #4 RenderConstrainedBox.performLayout (package:flutter/src/rendering/proxy_box.dart:277:14)
  11. #5 RenderObject.layout (package:flutter/src/rendering/object.dart:1858:7)
  12. #6 ChildLayoutHelper.layoutChild (package:flutter/src/rendering/layout_helper.dart:56:11)
  13. #7 RenderFlex._computeSizes (package:flutter/src/rendering/flex.dart:829:43)
  14. #8 RenderFlex.performLayout (package:flutter/src/rendering/flex.dart:931:32)
  15. #9 RenderObject.layout (package:flutter/src/rendering/object.dart:1858:7)
  16. #10 MultiChildLayoutDelegate.layoutChild (package:flutter/src/rendering/custom_layout.dart

在column中某个的组件的高度想充满整个剩余的位置,但是如果你不设置高度的话就会报以上这个错误,类似下面这种,就被报错

LoadStateLayout是我自己定义的一个加载页面,这个页面需要充满底部的高度,如何实现呢,用Expanded即可。

 

使用Expanded 包围整个的子组件,就可以撑满剩下的屏幕区域了

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/花生_TL007/article/detail/227291
推荐阅读
相关标签
  

闽ICP备14008679号