goToPage method

Future goToPage(
  1. int index
)

Implementation

Future goToPage(int index) async {
  if (mounted) {
    setState(() {
      pageNumber = index;
    });
  }
  for (var i = 0; i < _controllers.length; i++) {
    if (i == index) {
      _controllers[i].forward();
    } else if (i < index) {
      _controllers[i].reverse();
    } else {
      if (_controllers[i].status == AnimationStatus.reverse) {
        _controllers[i].value = 1;
      }
    }
  }

  currentPageIndex.value = pageNumber;
  currentWidget.value = pages[pageNumber];
  currentPage.value = pageNumber;
}