CarouselSlider class
A carousel slider widget.
This widget is useful when you have a bunch of widgets that you want to display in a carousel. It can be used to display images, cards, or any other widgets. It is similar to a ViewPager in Android. It is highly customizable and flexible. You can control the carousel manually by using the CarouselSliderController that is passed to the constructor.
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- CarouselSlider
Constructors
-
CarouselSlider.new({Key? key, required List<
Widget> ? items, CarouselOptions? options, bool disableGesture = false, CarouselSliderController? controller}) - Creates a carousel slider widget with a list of items The items will be created from the list of widgets that you pass to this constructor.
- CarouselSlider.builder({Key? key, required int? itemCount, required ExtendedIndexedWidgetBuilder? itemBuilder, CarouselOptions? options, bool disableGesture = false, CarouselSliderController? controller})
- Creates a carousel slider widget with a builder The items will be created using the builder that you pass to this constructor. This is useful for when you want to create the items on demand.
Properties
- carouselController → CarouselSliderController
-
The controller that can be used to control the carousel
This can be used to change the current page or to start the autoplay.
Defaults to a new instance of CarouselSliderController.
If you want to control the carousel manually,
you can pass your own instance of
CarouselSliderController to this constructor
final
- disableGesture → bool
-
Whether or not to disable touch gestures.
If this is set to true, the carousel will not respond to any touch events
and will not be able to be swiped or controlled by the user.
This is useful for when you want to control the carousel manually.
Defaults to false.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- itemBuilder → ExtendedIndexedWidgetBuilder?
-
The builder that will be used to create the carousel items.
This is useful for when you want to create the items on demand.
This is required if you are using the builder constructor.
The builder will be called with the context, the index of the item,
and the real index of the item.
The real index is the index of the item in the list of items
and is useful for when you are using infinite scroll.
final
- itemCount → int?
-
The number of items in the carousel
This is required if you are using the builder constructor
If you are using the list constructor, this will be set automatically
final
-
items
→ List<
Widget> ? -
The list of widgets that will be used to create the carousel items.
final
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- options → CarouselOptions
-
CarouselOptions to create a CarouselState with
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
createElement(
) → StatefulElement -
Creates a StatefulElement to manage this widget's location in the tree.
inherited
-
createState(
) → _CarouselSliderState -
Creates the mutable state for this widget at a given location in the tree.
override
-
debugDescribeChildren(
) → List< DiagnosticsNode> -
Returns a list of DiagnosticsNode objects describing this node's
children.
inherited
-
debugFillProperties(
DiagnosticPropertiesBuilder properties) → void -
Add additional properties associated with the node.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toDiagnosticsNode(
{String? name, DiagnosticsTreeStyle? style}) → DiagnosticsNode -
Returns a debug representation of the object that is used by debugging
tools and by DiagnosticsNode.toStringDeep.
inherited
-
toString(
{DiagnosticLevel minLevel = DiagnosticLevel.info}) → String -
A string representation of this object.
inherited
-
toStringDeep(
{String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) → String -
Returns a string representation of this node and its descendants.
inherited
-
toStringShallow(
{String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) → String -
Returns a one-line detailed description of the object.
inherited
-
toStringShort(
) → String -
A short, textual description of this widget.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited