我使用的是fluttercarousel_slider 4.2.1它工作完美,但在5秒有一个错误信息显示。
CarouselController carouselController = CarouselController();
return Container(
height: MediaQuery.of(context).size.height,
padding: EdgeInsets.only(top: 18, right: 20, left: 20),
decoration: BoxDecoration(
color: white,
borderRadius: BorderRadius.vertical(top: Radius.circular(18))),
child: ListView(
children: [
Container(
width: MediaQuery.of(context).size.width - 40,
decoration: BoxDecoration(
color: grey, borderRadius: BorderRadius.circular(24)),
height: 200,
child: ClipRRect(
borderRadius: BorderRadius.circular(24),
child: CarouselSlider(
carouselController: carouselController,
items: _imageList,
options: CarouselOptions(
autoPlay: true, autoPlayCurve: Curves.linear),
),
),
),
],
),
);
和这个错误显示在5秒
_AssertionError ('package:flutter/src/rendering/sliver_fixed_extent_list.dart': Failed assertion: line 270 pos 12: 'firstIndex == 0 || childScrollOffset(firstChild!)! - scrollOffset <= precisionErrorTolerance': is not true.)
我不知道你在_imageList里面放了什么但是要从_imageList返回widget你应该这样写_imageList.map((e) => put some widget here that you want for the carousel).toList()