animateToItem method

Future<void> animateToItem(
  1. int itemIndex,
  2. {required Duration duration,
  3. required Curve curve}

Animates the controlled scroll view to the given item index.

The animation lasts for the given duration and follows the given curve. The returned Future resolves when the animation completes.


Future<void> animateToItem(
  int itemIndex, {
  required Duration duration,
  required Curve curve,
}) async {
  if (!hasClients) {

  await Future.wait<void>(<Future<void>>[
    for (final _FixedExtentScrollPosition position in positions.cast<_FixedExtentScrollPosition>())
        itemIndex * position.itemExtent,
        duration: duration,
        curve: curve,