animateTo method

void animateTo(
  1. int value, {
  2. Duration? duration,
  3. Curve curve = Curves.ease,
})

Implementation

void animateTo(int value, {Duration? duration, Curve curve = Curves.ease}) {
  if (value == _index) {
    return;
  }

  _index = value;

  _indexIsChangingCount += 1;

  notifyListeners();

  _animationController!
      .animateTo(
    _index.toDouble(),
    duration: const Duration(milliseconds: 300),
    curve: Curves.ease,
  )
      .whenCompleteOrCancel(() {
    if (_animationController != null) {
      _indexIsChangingCount -= 1;

      notifyListeners();
    }
  });
}