animateTo method

void animateTo(
  1. int newIndex
)

Animates to the given newIndex, clamped to valid range.

Implementation

void animateTo(int newIndex) {
  final int clamped = newIndex.clamp(0, _length - 1);
  if (clamped == _index) return;
  _index = clamped;
  notifyListeners();
}