calculateScrollProgressByPageView method
ScrollProgressInfo?
calculateScrollProgressByPageView(
- int currentIndex,
- PageController pageController
Implementation
ScrollProgressInfo? calculateScrollProgressByPageView(
int currentIndex, PageController pageController) {
if (pageController.page == currentIndex) return null;
int targetIndex = 0;
if ((pageController.page ?? 0) > currentIndex) {
targetIndex = pageController.page!.ceil();
} else {
targetIndex = pageController.page!.floor();
}
_progress = pageController.page! % 1.0;
if (targetIndex < currentIndex) {
_progress = 1 - _progress;
}
_progress = _progress == 0 ? 1 : _progress;
return ScrollProgressInfo(
progress: _progress,
targetIndex: targetIndex,
currentIndex: currentIndex);
}