nextPage method

void nextPage()

Next page.

Implementation

void nextPage() {
  if (_paged) {
    if (_pageInChapter < _pages.length - 1) {
      _goToPageInChapter(_pageInChapter + 1);
    } else if (_hasNextChapter) {
      unawaited(_loadChapter(_controller.value.pageIndex + 1));
    }
    return;
  }
  if (!_scroll.hasClients) return;
  final double viewport = _scroll.position.viewportDimension;
  if (_scroll.offset >= _scroll.position.maxScrollExtent - 2) {
    if (_hasNextChapter) unawaited(_loadChapter(_controller.value.pageIndex + 1));
    return;
  }
  unawaited(_scroll.animateTo((_scroll.offset + viewport * 0.85).clamp(0, _scroll.position.maxScrollExtent).toDouble(), duration: const Duration(milliseconds: 240), curve: Curves.easeOut));
}