CarouselView class
A Material Design carousel widget.
The CarouselView present a scrollable list of items, each of which can dynamically change size based on the chosen layout.
This widget supports uncontained carousel layout. It shows items that scroll to the edge of the container, behaving similarly to a ListView where all children are a uniform size.
The CarouselController is used to control the CarouselController.initialItem.
The CarouselView.itemExtent property must be non-null and defines the base size of items. While items typically maintain this size, the first and last visible items may be slightly compressed during scrolling. The shrinkExtent property controls the minimum allowable size for these compressed items.
To create a local project with this code sample, run:
flutter create --sample=material.CarouselView.1 mysample
See also:
- CarouselController, which controls the first visible item in the carousel.
- PageView, which is a scrollable list that works page by page.
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- CarouselView
Constructors
-
CarouselView({Key? key, EdgeInsets? padding, Color? backgroundColor, double? elevation, ShapeBorder? shape, WidgetStateProperty<
Color?> ? overlayColor, bool itemSnapping = false, double shrinkExtent = 0.0, CarouselController? controller, Axis scrollDirection = Axis.horizontal, bool reverse = false, ValueChanged<int> ? onTap, required double itemExtent, required List<Widget> children}) -
Creates a Material Design carousel.
const
Properties
- backgroundColor → Color?
-
The background color for each carousel item.
final
-
children
→ List<
Widget> -
The child widgets for the carousel.
final
- controller → CarouselController?
-
An object that can be used to control the position to which this scroll
view is scrolled.
final
- elevation → double?
-
The z-coordinate of each carousel item.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- itemExtent → double
-
The extent the children are forced to have in the main axis.
final
- itemSnapping → bool
-
Whether the carousel should keep scrolling to the next/previous items to
maintain the original layout.
final
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
-
onTap
→ ValueChanged<
int> ? -
Called when one of the children is tapped.
final
-
overlayColor
→ WidgetStateProperty<
Color?> ? -
The highlight color to indicate the carousel items are in pressed, hovered
or focused states.
final
- padding → EdgeInsets?
-
The amount of space to surround each carousel item with.
final
- reverse → bool
-
Whether the carousel list scrolls in the reading direction.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- scrollDirection → Axis
-
The Axis along which the scroll view's offset increases with each item.
final
- shape → ShapeBorder?
-
The shape of each carousel item's Material.
final
- shrinkExtent → double
-
The minimum allowable extent (size) in the main axis for carousel items
during scrolling transitions.
final
Methods
-
createElement(
) → StatefulElement -
Creates a StatefulElement to manage this widget's location in the tree.
inherited
-
createState(
) → State< CarouselView> -
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}) → 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