pointerScroll method

  1. @override
void pointerScroll(
  1. double delta
)
override

Changes the scrolling position based on a pointer signal from current value to delta without animation and without checking if new value is in range, taking min/max scroll extent into account.

Any active animation is canceled. If the user is currently scrolling, that action is canceled.

This method dispatches the start/update/end sequence of scrolling notifications.

This method is very similar to jumpTo, but pointerScroll will update the ScrollDirection.

Implementation

@override
void pointerScroll(double delta) {
  // If an update is made to pointer scrolling here, consider if the same
  // (or similar) change should be made in
  // _NestedScrollCoordinator.pointerScroll.
  if (delta == 0.0) {
    goBallistic(0.0);
    return;
  }

  final double targetPixels =
      math.min(math.max(pixels + delta, minScrollExtent), maxScrollExtent);
  if (targetPixels != pixels) {
    goIdle();
    updateUserScrollDirection(
        -delta > 0.0 ? ScrollDirection.forward : ScrollDirection.reverse,
    );
    final double oldPixels = pixels;
    // Set the notifier before calling force pixels.
    // This is set to false again after going ballistic below.
    isScrollingNotifier.value = true;
    forcePixels(targetPixels);
    didStartScroll();
    didUpdateScrollPositionBy(pixels - oldPixels);
    didEndScroll();
    goBallistic(0.0);
  }
}