childMainAxisPosition method

  1. @protected
double childMainAxisPosition (covariant RenderObject child)
@protected

Returns the distance from the leading visible edge of the sliver to the side of the given child closest to that edge.

For example, if the constraints describe this sliver as having an axis direction of AxisDirection.down, then this is the distance from the top of the visible portion of the sliver to the top of the child. On the other hand, if the constraints describe this sliver as having an axis direction of AxisDirection.up, then this is the distance from the bottom of the visible portion of the sliver to the bottom of the child. In both cases, this is the direction of increasing SliverConstraints.scrollOffset and SliverLogicalParentData.layoutOffset.

For children that are RenderSlivers, the leading edge of the child will be the leading visible edge of the child, not the part of the child that would locally be a scroll offset 0.0. For children that are not RenderSlivers, for example a RenderBox child, it's the actual distance to the edge of the box, since those boxes do not know how to handle being scrolled.

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

Calling this for a child that is not visible is not valid.

Implementation

@protected
double childMainAxisPosition(covariant RenderObject child) {
  assert(() {
    throw FlutterError('$runtimeType does not implement childPosition.');
  }());
  return 0.0;
}