childCrossAxisPosition method

  1. @override
double childCrossAxisPosition(
  1. covariant RenderSliver child
)
override

Returns the distance along the cross axis from the zero of the cross axis in this sliver's paint coordinate space to the nearest side of the given child.

For example, if the constraints describe this sliver as having an axis direction of AxisDirection.down, then this is the distance from the left of the sliver to the left of the child. Similarly, if the constraints describe this sliver as having an axis direction of AxisDirection.up, then this is value is the same. If the axis direction is AxisDirection.left or AxisDirection.right, then it is the distance from the top of the sliver to the top of the child.

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

Implementation

@override
double childCrossAxisPosition(RenderSliver child) {
  assert(child == this.child);
  assert(resolvedPadding != null);
  return switch (constraints.axis) {
    Axis.horizontal => resolvedPadding!.top,
    Axis.vertical   => resolvedPadding!.left,
  };
}