SingleWebPageController constructor

SingleWebPageController({
  1. List<Snap> snaps = const [],
  2. double topSnapExtraOffset = 0,
  3. double centerSnapExtraOffset = 0,
  4. double bottomSnapExtraOffset = 0,
  5. void onAnimatedScrollStart(
    1. int currentIndex,
    2. int targetIndex
    )?,
  6. void onAnimatedScrollEnd(
    1. int currentIndex
    )?,
  7. void onScrollEnd(
    1. int lastVisibleIndex
    )?,
  8. bool triggerSameIndexAnimationEffect = true,
})

Implementation

SingleWebPageController({
  this.snaps = const [],
  this.topSnapExtraOffset = 0,
  this.centerSnapExtraOffset = 0,
  this.bottomSnapExtraOffset = 0,
  this.onAnimatedScrollStart,
  this.onAnimatedScrollEnd,
  this.onScrollEnd,
  this.triggerSameIndexAnimationEffect = true,
}) {
  addListener(() {
    if (!_isAnimating) {
      int visibleIndex = 0;
      _sectionHeights.forEach((index, _) {
        final snapOffset = _bottomSnapOffsets[index];
        if (snapOffset == null) {
          return;
        }
        if (position.pixels >= snapOffset) {
          visibleIndex = index;
        }
      });
      if (onScrollEnd != null) {
        onScrollEnd!(visibleIndex);
      }
    }
  });
}