【发布时间】:2022-01-19 12:38:46
【问题描述】:
我需要水平生成一个列表。但是,我面临以下问题:
发生异常时正在处理以下 RenderObject 解雇:CustomRenderShrinkWrappingViewport#f6727 relayoutBoundary=up17 需要-布局需要-油漆需要-合成-位-更新:需要 合成创建者:CustomShrinkWrappingViewport ← IgnorePointer-[GlobalKey#952f0] ← 语义 ← 监听器 ← _GestureSemantics ← RawGestureDetector-[LabeledGlobalKey#f0fc7] ← 监听器 ← _ScrollableScope ← _ScrollSemantics-[GlobalKey#c0651] ← RepaintBoundary ← CustomPaint ← RepaintBoundary ← ⋯ parentData:(可以使用大小)约束:BoxConstraints(0.0 RangeMaintainingScrollPhysics, IdleScrollActivity#d7dd2, ScrollDirection.idle) 锚点:0.0 此 RenderObject 具有以下后代(显示深度为 5): 子 0:RenderSliverPadding#963bb 需要-布局需要-绘制需要-合成-位更新 孩子:RenderSliverList#5357f 需要-布局需要-油漆 孩子 1:RenderSliverPadding#2291f 需要 - 布局需要 - 油漆需要 - 合成 - 位更新 child: RenderSliverList#6db77 需要-布局需要-油漆══════════════════════════════════ ══════════════════════════════════════════════════ ═══════════
抛出了另一个异常:RenderBox 未布局: CustomRenderShrinkWrappingViewport#f6727 relayoutBoundary=up17 需要-油漆需要-合成-位-更新
代码是:
CustomScrollView(
// physics: ScrollPhysics(),
scrollDirection: Axis.vertical,
slivers: [
SliverList(
delegate: SliverChildBuilderDelegate(
(context, index) => ScrollablePositionedList.builder(
shrinkWrap: true,
scrollDirection: Axis.horizontal,
itemScrollController: _scrollController,
itemCount: dummyQuestions.length,
itemBuilder: (context, index) {
currentPageIndex = index;
return dummyQuestions[index];
},
),
),
),
],
),
【问题讨论】: