onScrollNotification method

void onScrollNotification(
  1. ScrollNotification scrollNotification
)

Implementation

void onScrollNotification(ScrollNotification scrollNotification) {
  var curPageController = pageController;
  if (curPageController == null) {
    return;
  }
  if (scrollNotification is ScrollStartNotification) {
    if (scrollNotification.dragDetails != null) {
      // dragDetails 非空表示手指开始拖动
      _scrollFlingStartHandle = false;
      // 开始拖动通知dragging state
      onPageScrollStateStart();
    } else {
      // dragDetails 表示fling手势开始
      _scrollFlingStartHandle = true;
      onPageScrollStateSettling();
    }
  } else if (scrollNotification is ScrollUpdateNotification) {
    var scrollOffset = scrollNotification.metrics.pixels;
    if (scrollNotification.dragDetails == null) {
      // dragDetails 表示fling中
      if (!_scrollFlingStartHandle) {
        _scrollFlingStartHandle = true;
        onPageScrollStateSettling();
      }
    }
    onPageScroll(curPageController.page?.toInt() ?? 0, scrollOffset);
  } else if (scrollNotification is ScrollEndNotification) {
    onPageScrollStateIdle();
  }
}