scrollToIndex method
Scrolls the ScrollController to the given index with smooth animation.
index is the target index of the item (used with lists).
itemHeight is the height of a single item.
duration specifies the duration of the scroll animation.
curve defines the curve for the animation (defaults to Curves.easeInOut).
Implementation
Future<void> scrollToIndex(
int index,
double itemHeight, {
Duration duration = const Duration(milliseconds: 300),
Curve curve = Curves.easeInOut,
}) {
double offset = index * itemHeight;
return animateToPosition(offset, duration: duration, curve: curve);
}