BaseCarouselSlider constructor
BaseCarouselSlider({
- Key? key,
- required ExtendedIndexedWidgetBuilder? itemBuilder,
- required int itemCount,
- double? height = 40,
- int initialPage = 0,
- double viewportFraction = 1,
- bool enableInfiniteScroll = true,
- bool pauseAutoPlayInFiniteScroll = true,
- bool pauseAutoPlayOnTouch = true,
- bool? autoPlay,
- bool pageSnapping = true,
- bool enlargeCenterPage = false,
- Axis scrollDirection = Axis.horizontal,
- Duration autoPlayInterval = const Duration(seconds: 2),
- ValueChanged<
double?> ? onScrolled, - Curve autoPlayCurve = Curves.linear,
- ScrollPhysics? scrollPhysics,
- dynamic controller,
- Duration autoPlayAnimationDuration = const Duration(milliseconds: 600),
- dynamic onPageChanged(
- int? index,
- CarouselPageChangedReason reason
Implementation
BaseCarouselSlider(
{super.key,
required super.itemBuilder,
required int itemCount,
double? height = 40,
int initialPage = 0,
double viewportFraction = 1,
bool enableInfiniteScroll = true,
/// 有拖拽时不暂停滚动
bool pauseAutoPlayInFiniteScroll = true,
/// 是否启用手势
bool pauseAutoPlayOnTouch = true,
bool? autoPlay,
bool pageSnapping = true,
/// 播放完成后,暂停播放
bool enlargeCenterPage = false,
Axis scrollDirection = Axis.horizontal,
Duration autoPlayInterval = const Duration(seconds: 2),
ValueChanged<double?>? onScrolled,
Curve autoPlayCurve = Curves.linear,
ScrollPhysics? scrollPhysics,
CarouselController? controller,
/// 滚动间隔时间
Duration autoPlayAnimationDuration = const Duration(milliseconds: 600),
Function(int? index, CarouselPageChangedReason reason)? onPageChanged})
: super.builder(
itemCount: itemCount,
carouselController: controller,
options: CarouselOptions(
height: height,
pageSnapping: pageSnapping,
pauseAutoPlayOnTouch: pauseAutoPlayOnTouch,
pauseAutoPlayInFiniteScroll: pauseAutoPlayInFiniteScroll,
initialPage: initialPage,
autoPlayAnimationDuration: autoPlayAnimationDuration,
enableInfiniteScroll: enableInfiniteScroll,
autoPlay: autoPlay ?? itemCount > 1,
scrollDirection: scrollDirection,
viewportFraction: viewportFraction,
autoPlayInterval: autoPlayInterval,
autoPlayCurve: autoPlayCurve,
scrollPhysics: scrollPhysics,
onPageChanged: onPageChanged,
onScrolled: onScrolled,
enlargeCenterPage: enlargeCenterPage));