childCrossAxisPosition method

  1. @override
double childCrossAxisPosition(
  1. covariant RenderBox 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(RenderBox child) {
  final SliverGridParentData childParentData = child.parentData! as SliverGridParentData;
  return childParentData.crossAxisOffset!;
}