centerOffsetAdjustment property

  1. @override
double centerOffsetAdjustment
override

For a center sliver, the distance before the absolute zero scroll offset that this sliver can cover.

For example, if an AxisDirection.down viewport with an RenderViewport.anchor of 0.5 has a single sliver with a height of 100.0 and its centerOffsetAdjustment returns 50.0, then the sliver will be centered in the viewport when the scroll offset is 0.0.

The distance here is in the opposite direction of the RenderViewport.axisDirection, so values will typically be positive.

Implementation

@override
double get centerOffsetAdjustment {
  if (refreshStyle == RefreshStyle.Front) {
    final RenderViewportBase renderViewport =
        parent as RenderViewportBase<ContainerParentDataMixin<RenderSliver>>;
    return Math.max(0.0, -renderViewport.offset.pixels);
  }
  return 0.0;
}