scrollTo method

Future<void> scrollTo({
  1. required int index,
  2. double alignment = 0,
  3. double offset = 0,
  4. required Duration duration,
  5. Curve curve = Curves.linear,
  6. List<double> opacityAnimationWeights = const [40, 20, 40],
  7. TargetRectResolver? targetRectResolver,
})

Animates until the item at index is at alignment; see jumpTo.

A distant item is first jumped to about one viewport away, so long scrolls take duration without building the items in between. User input stops the animation. The future completes when the list has landed or the animation was interrupted.

opacityAnimationWeights is accepted for compatibility and ignored.

Implementation

Future<void> scrollTo({
  required int index,
  double alignment = 0,
  double offset = 0,
  required Duration duration,
  Curve curve = Curves.linear,
  List<double> opacityAnimationWeights = const [40, 20, 40],
  TargetRectResolver? targetRectResolver,
}) {
  assert(isAttached, "ItemScrollController is not attached.");
  return _client!._scrollTo(
    index: index,
    alignment: alignment,
    offset: offset,
    duration: duration,
    curve: curve,
    targetRectResolver: targetRectResolver,
  );
}