childScrollOffset method

  1. @override
double childScrollOffset(
  1. covariant RenderObject child
)
override

Returns the scroll offset for the leading edge of the given child.

The child must be a child of this sliver.

This method differs from childMainAxisPosition in that childMainAxisPosition gives the distance from the leading visible edge of the sliver whereas childScrollOffset gives the distance from sliver's zero scroll offset.

Implementation

@override
double childScrollOffset(RenderObject child) {
  // Computes the scroll offsets as if the position of the header is static.

  if (reverse) {
    if (child == _header) {
      return overlayHeader ? _bodyExtent - _headerExtent : _bodyExtent;
    } else {
      return 0;
    }
  } else {
    if (child == _header) {
      return 0;
    } else {
      return overlayHeader ? 0 : _headerExtent;
    }
  }
}