correctBy method Null safety

  1. @override
void correctBy(
  1. double correction
)
override

Apply a layout-time correction to the scroll offset.

This method should change the pixels value by correction, but without calling notifyListeners. It is called during layout by the RenderViewport, before applyContentDimensions. After this method is called, the layout will be recomputed and that may result in this method being called again, though this should be very rare.

See also:

Implementation

@override
void correctBy(double correction) {
  assert(
    hasPixels,
    'An initial pixels value must exist by calling correctPixels on the ScrollPosition',
  );
  _pixels = _pixels! + correction;
  _didChangeViewportDimensionOrReceiveCorrection = true;
}