A RenderViewport expected a child of type RenderSliver but received a child of type RenderConstrainedBox.
RenderObjects expect specific types of children because they coordinate with their children during layout and paint. For example, a RenderSliver cannot be the child of a RenderBox because a RenderSliver does not understand the RenderBox layout protocol.
The RenderViewport that expected a RenderSliver child was created by:
Viewport ← IgnorePointer-[GlobalKey#35d86] ← Semantics ← Listener ← _GestureSemantics ← RawGestureDetector-[LabeledGlobalKey<RawGestureDetectorState>#98863] ← Listener ← _ScrollableScope ← _ScrollSemantics-[GlobalKey#57f79] ← NotificationListener<ScrollMetricsNotification> ← RepaintBoundary ← CustomPaint ← ⋯
The RenderConstrainedBox that did not match the expected child type was created by:
SizedBox ← Viewport ← IgnorePointer-[GlobalKey#35d86] ← Semantics ← Listener ← _GestureSemantics ← RawGestureDetector-[LabeledGlobalKey<RawGestureDetectorState>#98863] ← Listener ← _ScrollableScope ← _ScrollSemantics-[GlobalKey#57f79] ← NotificationListener<ScrollMetricsNotification> ← RepaintBoundary ← ⋯
因为在CustomScrollView中都要是slivers类型的组件,如果有其他类型的组件放入其中,则要用
SliverToBoxAdapter 组件 包裹。
本文解析了在使用CustomScrollView时遇到的错误,原因在于试图将RenderConstrainedBox直接放置在需要RenderSliver子组件的视口内。正确做法是在非Sliver组件上使用SliverToBoxAdapter进行适配。
5326

被折叠的 条评论
为什么被折叠?



