animateTo method

Future animateTo({
  1. required GlobalKey<State<StatefulWidget>> nestedScrollViewKey,
  2. required SliverObserverController observerController,
  3. required NestedScrollUtilPosition position,
  4. required int index,
  5. required Duration duration,
  6. required Curve curve,
  7. required BuildContext? sliverContext,
  8. bool isFixedHeight = false,
  9. double alignment = 0,
  10. EdgeInsets padding = EdgeInsets.zero,
  11. ObserverLocateIndexOffsetCallback? offset,
  12. ObserverRenderSliverType? renderSliverType,
})

Animate to the specified index position.

Implementation

Future animateTo({
  required GlobalKey nestedScrollViewKey,
  required SliverObserverController observerController,
  required NestedScrollUtilPosition position,
  required int index,
  required Duration duration,
  required Curve curve,
  required BuildContext? sliverContext,
  bool isFixedHeight = false,
  double alignment = 0,
  EdgeInsets padding = EdgeInsets.zero,
  ObserverLocateIndexOffsetCallback? offset,
  ObserverRenderSliverType? renderSliverType,
}) {
  assert(outerScrollController != null, 'outerScrollController is null');
  assert(bodyScrollController != null, 'bodyScrollController is null');
  if (outerScrollController == null) return Future.value();
  if (bodyScrollController == null) return Future.value();
  switchScrollController(
    observerController: observerController,
    position: position,
  );

  return observerController.animateTo(
    index: index,
    duration: duration,
    curve: curve,
    sliverContext: sliverContext,
    isFixedHeight: isFixedHeight,
    alignment: alignment,
    padding: padding,
    offset: offset,
    renderSliverType: renderSliverType,
    onPrepareScrollToIndex: handleOnPrepareScrollToIndex(
      nestedScrollViewKey: nestedScrollViewKey,
      position: position,
      outerScrollController: outerScrollController!,
      duration: duration,
      curve: curve,
      offset: offset,
    ),
  );
}