CustomCarousel class
A widget that displays a list of children with fully customizable scrolling animations. It manages the visible subset of children based on itemCountBefore/itemCountAfter, and calls back to the supplied effectsBuilder method to wrap each child with the desired effects based on its scroll position relative to the selected item.
See the files in /example/lib/views/
for examples.
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatefulWidget
- CustomCarousel
Constructors
-
CustomCarousel({required EffectsBuilder effectsBuilder, required List<
Widget> children, Key? key, Axis scrollDirection = Axis.vertical, bool reverse = false, CustomCarouselScrollController? controller, ScrollPhysics? physics, bool addRepaintBoundaries = true, bool addSemanticIndexes = true, bool excludeFromSemantics = false, String? restorationId, ScrollBehavior? scrollBehavior, ValueChanged<int> ? onSelectedItemChanged, ValueChanged<int?> ? onSettledItemChanged, bool tapToSelect = true, int? itemCountBefore, int? itemCountAfter, double scrollSpeed = 1, DepthOrder depthOrder = DepthOrder.forward, bool loop = false, Alignment? alignment}) -
Creates an instance of CustomCarousel.
const
Properties
- addRepaintBoundaries → bool
-
Whether to wrap each child in a RepaintBoundary.
final
- addSemanticIndexes → bool
-
Whether to wrap each child in an IndexedSemantics.
final
- alignment → Alignment?
-
Sets a default visual alignment for children. This effectively just wraps
each child with its effects inside an Align widget. Setting it to
null
will remove the Align widget.final -
children
→ List<
Widget> -
The widgets to display.
final
- controller → CustomCarouselScrollController?
-
A CustomCarouselScrollController instance that can be used to control
the position to which this scroll view is scrolled. If none is provided,
a new CustomCarouselScrollController is implicitly created.
final
- depthOrder → DepthOrder
-
Determines the order in which items are displayed (ie. which items are in front of others).
See DepthOrder for options.
final
- effectsBuilder → EffectsBuilder
-
This method is responsible for animating the children based on the current scroll position.
final
- excludeFromSemantics → bool
-
Whether the scroll actions introduced by this Scrollable are exposed
in the semantics tree.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- itemCountAfter → int?
-
The number of items to display after the selected item.
A reasonable default will be calculated if not provided.
final
- itemCountBefore → int?
-
The number of items to display before the selected item.
A reasonable default will be calculated if not provided.
final
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- loop → bool
-
If
true
, the view will scroll infinitely in both directions, looping the list of items.final -
onSelectedItemChanged
→ ValueChanged<
int> ? -
An optional listener that's called when the selected item changes.
final
-
onSettledItemChanged
→ ValueChanged<
int?> ? -
An optional listener that's called with the item index when the scroll settles
or
null
when scrolling begins again.final - physics → ScrollPhysics?
-
How the scroll view should respond to user input.
final
- restorationId → String?
-
Restoration ID to save and restore the scroll offset of the scrollable.
final
- reverse → bool
-
Reverses the direction of scrolling interactions. For example if scrollDirection is Axis.horizontal
setting reverse to
true
will cause positive scrolling to be left to right, instead of right to left.final - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- scrollBehavior → ScrollBehavior?
-
A ScrollBehavior that will be applied to this widget individually.
final
- scrollDirection → Axis
-
Indicates the axis for scroll interactions (ex. swiping, scroll wheel).
Note that this does not affect the visual presentation of the scrolling
(which are controlled via effectsBuilder), just the direction for user inputs.
final
- scrollSpeed → double
-
Modifies the interaction between scroll gestures and the widget's scroll.
A higher number will scroll faster. Defaults to 1.
final
- tapToSelect → bool
-
If true, tapping an unselected item will animate to it as the new selection.
This will also display a SystemMouseCursors.click cursor on hover on desktop.
final
Methods
-
createElement(
) → StatefulElement -
Creates a StatefulElement to manage this widget's location in the tree.
inherited
-
createState(
) → State< CustomCarousel> -
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
Static Methods
-
effectsBuilderFromAnimate(
{required List< Effect> effects}) → EffectsBuilder - A helper function that makes it easier to create an effectsBuilder method using effects from the Flutter Animate package.