goToPage method
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;
}