抛出另一个异常:RenderBox was not layout: CustomRenderShrinkWrappingViewport#f6727 relayoutBoundary=up17 NEEDS-PAINT NEEDS-COMPOSITING
Another exception was thrown: RenderBox was not laid out: CustomRenderShrinkWrappingViewport#f6727 relayoutBoundary=up17 NEEDS-PAINT NEEDS-COMPOSITING
我需要横向生成一个列表。但是,我面临以下问题:
The following RenderObject was being processed when the exception was
fired: CustomRenderShrinkWrappingViewport#f6727 relayoutBoundary=up17
NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE: needs
compositing creator: CustomShrinkWrappingViewport ←
IgnorePointer-[GlobalKey#952f0] ← Semantics ← Listener ←
_GestureSemantics ← RawGestureDetector-[LabeledGlobalKey#f0fc7] ←
Listener ← _ScrollableScope ← _ScrollSemantics-[GlobalKey#c0651] ← RepaintBoundary ← CustomPaint ←
RepaintBoundary ← ⋯ parentData: (can use size) constraints: BoxConstraints(0.0<=w<=331.2, 0.0<=h<=Infinity) size:
MISSING axisDirection: right crossAxisDirection: down offset:
ScrollPositionWithSingleContext#c3ca2(offset: 0.0, range: null..null,
viewport: null,
ScrollableState, ClampingScrollPhysics -> RangeMaintainingScrollPhysics, IdleScrollActivity#d7dd2,
ScrollDirection.idle) anchor: 0.0 This RenderObject had the following descendants (showing up to depth 5):
child 0: RenderSliverPadding#963bb NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
child: RenderSliverList#5357f NEEDS-LAYOUT NEEDS-PAINT
child 1: RenderSliverPadding#2291f NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
child: RenderSliverList#6db77 NEEDS-LAYOUT NEEDS-PAINT ════════════════════════════════════════════════════════════════════════════════════════════════════
Another exception was thrown: RenderBox was not laid out:
CustomRenderShrinkWrappingViewport#f6727 relayoutBoundary=up17
NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
代码是:
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];
},
),
),
),
],
),
请参考以下代码:
CustomScrollView(
controller: scrollController,
scrollDirection: Axis.horizontal,
slivers: <Widget>[
SliverList(
delegate: SliverChildBuilderDelegate(
(_, int index) {
return Container(
child: Text(list[index]['index'],),
);
},
childCount: list.length,
)
),
],
))
我需要横向生成一个列表。但是,我面临以下问题:
The following RenderObject was being processed when the exception was fired: CustomRenderShrinkWrappingViewport#f6727 relayoutBoundary=up17 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE: needs compositing creator: CustomShrinkWrappingViewport ← IgnorePointer-[GlobalKey#952f0] ← Semantics ← Listener ← _GestureSemantics ← RawGestureDetector-[LabeledGlobalKey#f0fc7] ← Listener ← _ScrollableScope ← _ScrollSemantics-[GlobalKey#c0651] ← RepaintBoundary ← CustomPaint ← RepaintBoundary ← ⋯ parentData: (can use size) constraints: BoxConstraints(0.0<=w<=331.2, 0.0<=h<=Infinity) size: MISSING axisDirection: right crossAxisDirection: down offset: ScrollPositionWithSingleContext#c3ca2(offset: 0.0, range: null..null, viewport: null, ScrollableState, ClampingScrollPhysics -> RangeMaintainingScrollPhysics, IdleScrollActivity#d7dd2, ScrollDirection.idle) anchor: 0.0 This RenderObject had the following descendants (showing up to depth 5): child 0: RenderSliverPadding#963bb NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE child: RenderSliverList#5357f NEEDS-LAYOUT NEEDS-PAINT child 1: RenderSliverPadding#2291f NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE child: RenderSliverList#6db77 NEEDS-LAYOUT NEEDS-PAINT ════════════════════════════════════════════════════════════════════════════════════════════════════
Another exception was thrown: RenderBox was not laid out: CustomRenderShrinkWrappingViewport#f6727 relayoutBoundary=up17 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
代码是:
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];
},
),
),
),
],
),
请参考以下代码:
CustomScrollView(
controller: scrollController,
scrollDirection: Axis.horizontal,
slivers: <Widget>[
SliverList(
delegate: SliverChildBuilderDelegate(
(_, int index) {
return Container(
child: Text(list[index]['index'],),
);
},
childCount: list.length,
)
),
],
))