Column(
children: [
if (state.bumperBountyData.isNotEmpty)
CarouselSlider(
items: state.bumperBountyData.map((e) {
return Container(
height: 200,
color: Colors.red,
);
}).toList(),
options: CarouselOptions(
enableInfiniteScroll:
state.bumperBountyData.length > 1,
viewportFraction: 0.85,
onPageChanged: (index, reason) {
state.bumperBountyCurrentIndex = index;
state.update([
ProductBySectionController
.bumperBountyListUpdate
]);
},
aspectRatio: 1.3,
pauseAutoPlayOnTouch: true,
enlargeCenterPage: false,
disableCenter: false,
padEnds: !(state.bumperBountyData.length > 1),
autoPlay: state.bumperBountyData.length > 1,
),
),
],
),
CarouselSlider 工作得很好,但调试控制台中不断弹出错误。
════════渲染库捕获异常 ═════════════════════════════════ 'package:flutter/src/rendering/sliver_fixed_extent_list.dart': 失败 断言:第 338 行 pos 12:'firstIndex == 0 || childScrollOffset(firstChild!)! - 滚动偏移<= precisionErrorTolerance': is not true.
我认为旋转木马滑块位于柱内是
的原因错误。如果删除该列,错误就会消失,或者您可以将
带有扩展或灵活小部件的轮播滑块,或者您可以用
包裹它SizedBox 并指定其高度。