我需要水平生成一個串列。但是,我面臨以下問題:
觸發例外時正在處理以下渲染物件:CustomRenderShrinkWrappingViewport#f6727relayoutBoundary=up17 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE:需要合成創建者:CustomShrinkWrappingViewport ← IgnorePointer-[GlobalKey←#952mantics0 _GestureSemantics ← RawGestureDetector-[LabeledGlobalKey#f0fc7] ← 監聽器 ← _ScrollableScope ← _ScrollSemantics-[GlobalKey#c0651] ← RepaintBoundary ← CustomPaint ← RepaintBoundary ← ? parentData:(可以使用大小)約束:BoxConstraint(<0.30s. =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) 錨點:0.0 這個 RenderObject 有以下后代(顯示深度 5): child 0:RenderSliv??erPadding#963bb NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE child:RenderSliv??erList#5357f -LAYOUT NEEDS-PAINT child 1:RenderSliv??erPadding#2291f NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE child:RenderSliv??erList#6db77 NEEDS-LAYOUT NEEDS-PAINT ============= ================================================= ===================================RenderSliv??erPadding#2291f NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE 子項:RenderSliv??erList#6db77 NEEDS-LAYOUT NEEDS-PAINT ==================== ================================================= ===========================RenderSliv??erPadding#2291f NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE 子項:RenderSliv??erList#6db77 NEEDS-LAYOUT NEEDS-PAINT ==================== ================================================= ===========================
拋出了另一個例外:RenderBox 沒有布局:CustomRenderShrinkWrappingViewport#f6727relayoutBoundary=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];
},
),
),
),
],
),
uj5u.com熱心網友回復:
請參考以下代碼:
CustomScrollView(
controller: scrollController,
scrollDirection: Axis.horizontal,
slivers: <Widget>[
SliverList(
delegate: SliverChildBuilderDelegate(
(_, int index) {
return Container(
child: Text(list[index]['index'],),
);
},
childCount: list.length,
)
),
],
))
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/383464.html
