animateToIndex method

void animateToIndex(
  1. int index
)

Animate to a specific card index (horizontal). Only allowed when verticalProgress == 0.0 (collapsed).

Implementation

void animateToIndex(int index) {
  if (verticalProgress > 0.01) return;
  final clamped = index.clamp(0, itemCount - 1);
  if (clamped != _state.currentIndex) {
    _state = _state.copyWith(currentIndex: clamped);
    notifyListeners();
  }
}