解决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(
        ......
      )
    )
  ]
)
相关文章
Failed to execute ‘setAttribute‘ on ‘Element‘: ‘;min-height:‘ is not a valid attribute name.添加100vh
Failed to execute ‘setAttribute‘ on ‘Element‘: ‘;min-height:‘ is not a valid attribute name.添加100vh
|
6月前
|
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
44 1
|
前端开发 容器
你真的了解position吗?
你真的了解position吗?
|
Android开发 数据格式 JSON
android报错 Expected BEGIN_OBJECT but was STRING at line 1 column 39 path $
      我在使用retrofit和Gson配合时,出现了这个问题,疑惑中乱七八糟瞎搞了一个下午没有解决。期间怀疑Gson解析不能使用泛型(因为我的解析使用了泛型),后来又觉得可能是我的关键字正好是解析器的某个关键字导致的异常,也打算过自定义Gson的解析过程,其实这些都不是。         第二天才搞明白,真正的问题是我的数据结构有问题,或者说我的解析出现了问题。  
4337 0
$ 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.
2553 0