animateTo method

Future<void> animateTo(
  1. int index, {
  2. Duration? duration,
  3. Curve? curve,
})

Implementation

Future<void> animateTo(int index, {Duration? duration, Curve? curve}) async {
  // Calculate the offset based on the smaller page width
  double screenWidth = state.context.size!.width;
  double pageWidth = screenWidth * pageFraction;

  double offset = index * pageWidth; // Updated to use the page width fraction

  if (state.boardViewController.hasClients) {
    await state.boardViewController
        .animateTo(offset, duration: duration!, curve: curve!);
  }
}