animateToPage method

Future<void> animateToPage(
  1. int page, {
  2. Duration duration = const Duration(milliseconds: 300),
  3. Curve curve = Curves.linear,
})

Animates the controlled CarouselSlider from the current page to the given page.

The animation lasts for the given duration and follows the given curve. The returned Future resolves when the animation completes.

page is an item index, brought into range the same way jumpToPage brings it.

Implementation

Future<void> animateToPage(
  int page, {
  Duration duration = const Duration(milliseconds: 300),
  Curve curve = Curves.linear,
}) async {
  await _onAnimateToPageCallback?.call(page, duration, curve);
}