InfiniteCarousel.builder constructor
InfiniteCarousel.builder(
- {Key? key,
- required int itemCount,
- required double itemExtent,
- required Widget itemBuilder(
- BuildContext context,
- int itemIndex,
- int realIndex
- ScrollPhysics? physics,
- ScrollController? controller,
- void onIndexChanged( )?,
- double anchor = 0.0,
- bool loop = true,
- double velocityFactor = 0.2,
- Axis axisDirection = Axis.horizontal,
- bool center = true,
- ScrollBehavior? scrollBehavior}
Infinite Carousel
Based on ListWheelScrollView to create smooth scroll effect and physics.
Implementation
InfiniteCarousel.builder({
super.key,
required this.itemCount,
required this.itemExtent,
required this.itemBuilder,
this.physics,
this.controller,
this.onIndexChanged,
this.anchor = 0.0,
this.loop = true,
this.velocityFactor = 0.2,
this.axisDirection = Axis.horizontal,
this.center = true,
this.scrollBehavior,
}) : assert(itemExtent > 0),
assert(itemCount > 0),
assert(velocityFactor > 0.0 && velocityFactor <= 1.0),
childDelegate = SliverChildBuilderDelegate(
(context, index) =>
itemBuilder(context, index.abs() % itemCount, index),
childCount: loop ? null : itemCount,
),
reversedChildDelegate = loop
? SliverChildBuilderDelegate(
(context, index) => itemBuilder(context,
itemCount - (index.abs() % itemCount) - 1, -(index + 1)),
)
: null;