animateToIndex method
If the current origin-index is already the same as the given index
,
animates the position from its current value to the 0.0 position
relative to the origin-index.
The returned Future will complete when the animation ends, whether it completed successfully or whether it was interrupted prematurely.
However, if the current origin-index is different from the given index
,
this will jump to the new position, without any animation.
Implementation
Future<void> animateToIndex(
int index, {
Duration duration = const Duration(milliseconds: 750),
Curve curve = Curves.decelerate,
}) {
return animateToIndexAndOffset(index: index, offset: 0.0, duration: duration, curve: curve);
}