Carousel constructor
const
Carousel({
- Key? key,
- required Widget itemBuilder(
- BuildContext context,
- int index
- int? itemCount,
- CarouselController? controller,
- CarouselAlignment alignment = CarouselAlignment.center,
- Axis direction = Axis.horizontal,
- bool wrap = true,
- bool pauseOnHover = true,
- Duration? autoplaySpeed,
- bool waitOnStart = false,
- bool draggable = true,
- bool reverse = false,
- bool autoplayReverse = false,
- CarouselSizeConstraint sizeConstraint = const CarouselFractionalConstraint(1),
- Duration speed = const Duration(milliseconds: 200),
- Curve curve = Curves.easeInOut,
- Duration? duration,
- Duration? durationBuilder(
- int index
- ValueChanged<
int> ? onIndexChanged, - bool disableOverheadScrolling = true,
- bool disableDraggingVelocity = false,
- required CarouselTransition transition,
Creates a carousel.
Implementation
const Carousel({
super.key,
required this.itemBuilder,
this.itemCount,
this.controller,
this.alignment = CarouselAlignment.center,
this.direction = Axis.horizontal,
this.wrap = true,
this.pauseOnHover = true,
this.autoplaySpeed,
this.waitOnStart = false,
this.draggable = true,
this.reverse = false,
this.autoplayReverse = false,
this.sizeConstraint = const CarouselFractionalConstraint(1),
this.speed = const Duration(milliseconds: 200),
this.curve = Curves.easeInOut,
this.duration,
this.durationBuilder,
this.onIndexChanged,
this.disableOverheadScrolling = true,
this.disableDraggingVelocity = false,
required this.transition,
}) : assert(wrap || itemCount != null,
'itemCount must be provided if wrap is false');