animateToItem method
void
animateToItem({})
Animates the position of the scroll view such that the item at index is
revealed in the viewport.
The optional rect parameter describes which area of that target item
should be revealed in the viewport. If omitted, the entire item
will be revealed (subject to the constraints of the viewport).
The alignment parameter controls where the item is positioned in the
viewport. If the value is 0.0, the item will be positioned at the leading
edge of the viewport. If the value is 0.5, the item will be positioned in
the middle of the viewport. If the value is 1.0, the item will be
positioned at the trailing edge of the viewport.
Implementation
void animateToItem({
required int index,
required ScrollController scrollController,
required double alignment,
required Duration Function(double estimatedDistance) duration,
required Curve Function(double estimatedDistance) curve,
Rect? rect,
}) {
assert(_delegate != null, "ListController is not attached.");
for (final position in scrollController.positions) {
AnimateToItem(
extentManager: _delegate!,
index: index,
alignment: alignment,
rect: rect,
position: position,
curve: curve,
duration: duration,
).animate();
}
}