CarouselOptions class
Everything about a CarouselSlider except what it shows.
Immutable and const-constructible: build a new one and rebuild the
carousel to change any of it.
Changing initialPage or enableInfiniteScroll puts the reader back on initialPage — both say where the carousel starts, so both start it again.
Two are meant to be set once rather than switched at runtime: changing pageViewKey, or swapping height for aspectRatio, rebuilds the page view from scratch and loses the reader's place along with anything inside a slide.
Constructors
-
CarouselOptions({double? height, double aspectRatio = 16 / 9, double viewportFraction = 0.8, int initialPage = 0, bool enableInfiniteScroll = true, bool animateToClosest = true, bool reverse = false, bool autoPlay = false, Duration autoPlayInterval = const Duration(seconds: 4), Duration autoPlayAnimationDuration = const Duration(milliseconds: 800), Curve autoPlayCurve = Curves.fastOutSlowIn, bool enlargeCenterPage = false, ScrollPhysics? scrollPhysics, bool pageSnapping = true, Axis scrollDirection = Axis.horizontal, PageStorageKey<
Object> ? pageViewKey, CenterPageEnlargeStrategy enlargeStrategy = CenterPageEnlargeStrategy.scale, double enlargeFactor = 0.3, bool disableCenter = false, Set<PointerDeviceKind> dragDevices = defaultDragDevices, bool padEnds = true, Clip clipBehavior = Clip.hardEdge}) -
Creates the options for a CarouselSlider.
const
Properties
- animateToClosest → bool
-
Determines if carousel should loop to the closest occurrence of requested page.
final
- aspectRatio → double
-
Aspect ratio is used if no height have been declared.
final
- autoPlay → bool
-
Enables auto play, sliding one page at a time.
final
- autoPlayAnimationDuration → Duration
-
The animation duration between two transitioning pages while in auto playback.
final
- autoPlayCurve → Curve
-
Determines the animation curve physics.
final
- autoPlayInterval → Duration
-
How often the carousel moves itself, measured from one slide to the next.
final
- clipBehavior → Clip
-
Exposed clipBehavior of PageView
final
- disableCenter → bool
-
Whether or not to disable the
Centerwidget for each slide.final -
dragDevices
→ Set<
PointerDeviceKind> -
The device kinds that can page the carousel by dragging it.
final
- enableInfiniteScroll → bool
-
Determines if carousel should loop infinitely or be limited to item length.
final
- enlargeCenterPage → bool
-
Determines if current page should be larger than the side images,
creating a feeling of depth in the carousel.
final
- enlargeFactor → double
-
How much the pages next to the center page will be scaled down.
If enlargeCenterPage is false, this property has no effect.
final
- enlargeStrategy → CenterPageEnlargeStrategy
-
How the centre page is made to stand out.
final
- hashCode → int
-
The hash code for this object.
no setteroverride
- height → double?
-
Set carousel height and overrides any existing aspectRatio.
final
- initialPage → int
-
The initial page to show when first creating the CarouselSlider.
final
- padEnds → bool
-
Whether to add padding to both ends of the list.
If this is set to true and viewportFraction < 1.0, padding will be added such that the first and last child slivers will be in the center of the viewport when scrolled all the way to the start or end, respectively.
If viewportFraction >= 1.0, this property has no effect.
This property defaults to true and must not be null.
final
- pageSnapping → bool
-
Set to false to disable page snapping, useful for custom scroll behavior.
final
-
pageViewKey
→ PageStorageKey<
Object> ? -
Pass a PageStorageKey if you want to keep the PageView's position when
it was recreated.
final
- reverse → bool
-
Reverse the order of items if set to true.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- scrollDirection → Axis
-
The axis along which the page view scrolls.
final
- scrollPhysics → ScrollPhysics?
-
How the carousel should respond to user input.
final
- viewportFraction → double
-
The fraction of the viewport that each page should occupy.
final
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
override
Constants
-
defaultDragDevices
→ const Set<
PointerDeviceKind> - Every PointerDeviceKind, the default for dragDevices.