CarouselSlider(
items: packList.map((item){
return InkWell(
child: item,
onTap: (){
},
);
}).toList(),
carouselController: _controller,
options: CarouselOptions(
autoPlay: true,
enlargeCenterPage: true,
height: 230,
autoPlayInterval: const Duration(seconds: 3),
autoPlayAnimationDuration: const Duration(milliseconds: 800),
autoPlayCurve: Curves.fastOutSlowIn,
pauseAutoPlayOnTouch: true,
viewportFraction: 0.51,
onPageChanged: (index, reason) {
setState(() {
_current = index;
});
}
),
)
1条答案
按热度按时间qv7cva1a1#
我假设您使用的是
carousel_slider
包,您可以在每次当前索引改变时更新items
参数,使具有当前索引的项与其他项不同。因此,如果项的索引等于当前索引,则返回不同的widget,否则返回正常的widget。例如,如果您希望中心小部件用红色容器 Package ,那么您将得到以下
CarouselSlider
。