解决RenderUiKitView object was given an infinite size during layout.

简介: 解决RenderUiKitView object was given an infinite size during layout.

场景

有个需求,需要在Column中放个Webview。

Column(
  children: [
    Text(....),
    Text(....),
    Webview(
      .....
    )
  ]
)

运行后控制台显示以下错误

════════ Exception caught by rendering library ═════════════════════════════════════════════════════
The following assertion was thrown during performLayout():
RenderUiKitView object was given an infinite size during layout.

This probably means that it is a render object that tries to be as big as possible, but it was put inside another render object that allows its children to pick their own size.
The nearest ancestor providing an unbounded height constraint is: RenderFlex#dbb0a relayoutBoundary=up2 NEEDS-LAYOUT NEEDS-COMPOSITING-BITS-UPDATE OVERFLOWING
...  parentData: offset=Offset(30.0, 0.0) (can use size)
...  constraints: BoxConstraints(0.0<=w<=354.0, 0.0<=h<=840.0)
...  size: Size(354.0, 840.0)
...  direction: vertical
...  mainAxisAlignment: start
...  mainAxisSize: max
...  crossAxisAlignment: center
...  verticalDirection: down
The constraints that applied to the RenderUiKitView were: BoxConstraints(0.0<=w<=354.0, 0.0<=h<=Infinity)
The exact size it was given was: Size(354.0, Infinity)

See https://flutter.dev/docs/development/ui/layout/box-constraints for more information.

解决方法

根据错误信息描述,原因是在渲染控件时,Webview是无限大的,在Column中是不允许这样的。我们只需要使用Expanded将其包裹即可。

Column(
  children: [
    Text(....),
    Text(....),
    Expanded(
      child: Webview(
        ......
      )
    )
  ]
)
相关文章
|
8月前
|
Android开发
Can t process attribute android:fillColor=@color/camera_progress_delete: references to other resou
Can t process attribute android:fillColor=@color/camera_progress_delete: references to other resou
52 1
|
8月前
|
前端开发
line-height与height的区别
line-height与height的区别
82 0
|
Android开发
Android 中setMargins和setPadding的区别
Android 中setMargins和setPadding的区别
166 0
|
XML Android开发 数据格式
View默认的LayoutParams是何时生成的,默认值是什么。layout_width和layout_height属性在哪里生效
View默认的LayoutParams是何时生成的,默认值是什么。layout_width和layout_height属性在哪里生效
|
Android开发 数据格式 XML
$ gradle packageDebug --stacktrace error: top-left corner pixel must be either opaque white or transparent.
$ gradle packageDebug --stacktrace error: top-left corner pixel must be either opaque white or transparent.
2560 0
Error:top-left corner pixel must be either opaque white or transparent.
Error:top-left corner pixel must be either opaque white or transparent. Information:Gradle tasks [:app:assembleDebug] Error:to...
2810 0