jumpToPage method
Jumps immediately to the specified page index.
Note that the page index is not checked to be within the range of the scroll view's pages.
Example
final controller = PageController();
controller.jumpToPage(2);
Implementation
void jumpToPage(int page) {
if (_attachedElement == null) return;
final isHoriz = direction == ScrollDirection.horizontal;
// calculate page size
final pageSize =
(isHoriz
? _attachedElement!.clientWidth
: _attachedElement!.clientHeight) *
viewportFraction;
// calculate target scroll offset
final targetOffset = page * pageSize;
// update scroll position
if (isHoriz) {
_attachedElement!.scrollLeft = targetOffset;
} else {
_attachedElement!.scrollTop = targetOffset;
}
// notify listeners of scroll position changes
notifyListeners();
}