applyPhysicsToUserOffset method

  1. @override
double applyPhysicsToUserOffset(
  1. ScrollMetrics position,
  2. double offset
)
override

Used by DragScrollActivity and other user-driven activities to convert an offset in logical pixels as provided by the DragUpdateDetails into a delta to apply (subtract from the current position) using ScrollActivityDelegate.setPixels.

This is used by some ScrollPosition subclasses to apply friction during overscroll situations.

This method must not adjust parts of the offset that are entirely within the bounds described by the given position.

The given position is only valid during this method call. Do not keep a reference to it to use later, as the values may update, may not update, or may update to reflect an entirely unrelated scrollable.

Implementation

@override
double applyPhysicsToUserOffset(ScrollMetrics position, double offset) {
  goesBottom = offset.sign > 0;
  goesTop = offset.sign < 0;
  return offset;
}