BasicCarouselSlider constructor

BasicCarouselSlider({
  1. Key? key,
  2. required ExtendedIndexedWidgetBuilder? itemBuilder,
  3. required int itemCount,
  4. double? height = 40,
  5. int initialPage = 0,
  6. double viewportFraction = 1,
  7. bool enableInfiniteScroll = true,
  8. bool pauseAutoPlayInFiniteScroll = true,
  9. bool pauseAutoPlayOnTouch = true,
  10. bool? autoPlay,
  11. bool pageSnapping = true,
  12. bool enlargeCenterPage = false,
  13. Axis scrollDirection = Axis.horizontal,
  14. Duration autoPlayInterval = const Duration(seconds: 2),
  15. ValueChanged<double?>? onScrolled,
  16. Curve autoPlayCurve = Curves.linear,
  17. ScrollPhysics? scrollPhysics,
  18. dynamic controller,
  19. Duration autoPlayAnimationDuration = const Duration(milliseconds: 600),
  20. dynamic onPageChanged(
    1. int? index,
    2. CarouselPageChangedReason reason
    )?,
})

Implementation

BasicCarouselSlider(
    {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));