correctForNewDimensions method

  1. @protected
bool correctForNewDimensions(
  1. ScrollMetrics oldPosition,
  2. ScrollMetrics newPosition
)

Verifies that the new content and viewport dimensions are acceptable.

Called by applyContentDimensions to determine its return value.

Should return true if the current scroll offset is correct given the new content and viewport dimensions.

Otherwise, should call correctPixels to correct the scroll offset given the new dimensions, and then return false.

This is only called when haveDimensions is true.

The default implementation defers to ScrollPhysics.adjustPositionForNewDimensions.

Implementation

@protected
bool correctForNewDimensions(ScrollMetrics oldPosition, ScrollMetrics newPosition) {
  final double newPixels = physics.adjustPositionForNewDimensions(
    oldPosition: oldPosition,
    newPosition: newPosition,
    isScrolling: activity!.isScrolling,
    velocity: activity!.velocity,
  );
  if (newPixels != pixels) {
    correctPixels(newPixels);
    return false;
  }
  return true;
}