setChildParentData method Null safety

  1. @protected
void setChildParentData(
  1. RenderObject child,
  2. SliverConstraints constraints,
  3. SliverGeometry geometry
)

Sets the SliverPhysicalParentData.paintOffset for the given child according to the SliverConstraints.axisDirection and SliverConstraints.growthDirection and the given geometry.

Implementation

@protected
void setChildParentData(RenderObject child, SliverConstraints constraints, SliverGeometry geometry) {
  final SliverPhysicalParentData childParentData = child.parentData! as SliverPhysicalParentData;
  assert(constraints.axisDirection != null);
  assert(constraints.growthDirection != null);
  switch (applyGrowthDirectionToAxisDirection(constraints.axisDirection, constraints.growthDirection)) {
    case AxisDirection.up:
      childParentData.paintOffset = Offset(0.0, -(geometry.scrollExtent - (geometry.paintExtent + constraints.scrollOffset)));
      break;
    case AxisDirection.right:
      childParentData.paintOffset = Offset(-constraints.scrollOffset, 0.0);
      break;
    case AxisDirection.down:
      childParentData.paintOffset = Offset(0.0, -constraints.scrollOffset);
      break;
    case AxisDirection.left:
      childParentData.paintOffset = Offset(-(geometry.scrollExtent - (geometry.paintExtent + constraints.scrollOffset)), 0.0);
      break;
  }
  assert(childParentData.paintOffset != null);
}