CardCarouselController class

Central controller for the morphing card carousel.

A single AnimationController drives vertical morph progress (0.0 → 1.0). Horizontal carousel index is tracked independently via deterministic resolution — no implicit scroll state.

Follows the TabController pattern: requires a TickerProvider at construction.

Usage

class _MyState extends State<MyPage>
    with SingleTickerProviderStateMixin {
  late final CardCarouselController _ctrl;

  @override
  void initState() {
    super.initState();
    _ctrl = CardCarouselController(vsync: this, itemCount: items.length);
  }
}
Inheritance

Constructors

CardCarouselController({required TickerProvider vsync, required int itemCount, int initialIndex = 0, Duration expandDuration = const Duration(milliseconds: 380), Duration collapseDuration = const Duration(milliseconds: 340), Curve expandCurve = Curves.easeOutCubic, Curve collapseCurve = Curves.easeInOutCubic, double verticalDragThreshold = 0.35, double velocityThresholdVertical = 800.0})

Properties

animation Animation<double>
Raw animation for AnimatedBuilder usage.
no setter
collapseCurve Curve
Curve for collapse animation.
final
collapseDuration Duration
Duration for collapse animation.
final
currentIndex int
no setter
expandCurve Curve
Curve for expand animation.
final
expandDuration Duration
Duration for expand animation.
final
hashCode int
The hash code for this object.
no setterinherited
hasListeners bool
Whether any listeners are currently registered.
no setterinherited
isAnimating bool
no setter
isDragging bool
no setter
itemCount int
no setter
phase CardPhase
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
state CardCarouselState
no setter
velocityThresholdVertical double
Velocity (px/s) to trigger expand/collapse flick.
final
verticalDragThreshold double
Fraction of screen height that must be dragged to trigger expand/collapse when velocity is below threshold.
final
verticalProgress double
no setter

Methods

addListener(VoidCallback listener) → void
Register a closure to be called when the object changes.
inherited
animateToIndex(int index) → void
Animate to a specific card index (horizontal). Only allowed when verticalProgress == 0.0 (collapsed).
collapse({Duration? duration, Curve? curve}) → void
Animate fullscreen back to card.
dispose() → void
Discards any resources used by the object. After this is called, the object is not in a usable state and should be discarded (calls to addListener will throw after the object is disposed).
override
expand({Duration? duration, Curve? curve}) → void
Animate card to fullscreen.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
notifyListeners() → void
Call all the registered listeners.
inherited
onVerticalDragEnd(double velocity, double availableHeight) → void
onVerticalDragStart() → void
onVerticalDragUpdate(double delta, double availableHeight) → void
removeListener(VoidCallback listener) → void
Remove a previously registered closure from the list of closures that are notified when the object changes.
inherited
resolveHorizontalSnap({required double velocity, required double displacement, required double cardWidth}) → void
Resolve index from horizontal gesture using CarouselSnapResolver.
setIndex(int index) → void
Set index directly (from thumbnail tap or snap resolver).
toString() String
A string representation of this object.
inherited
updateItemCount(int count) → void
Update item count (e.g. when items list changes).

Operators

operator ==(Object other) bool
The equality operator.
inherited