setChildParentData method
- RenderObject child,
- SliverConstraints constraints,
- SliverGeometry geometry
override
Sets the SliverPhysicalParentData.paintOffset for the given child according to the SliverConstraints.axisDirection and SliverConstraints.growthDirection and the given geometry.
Implementation
@override
void setChildParentData(
RenderObject child,
SliverConstraints constraints,
SliverGeometry geometry,
) {
super.setChildParentData(child, constraints, geometry);
if (child is! RenderBox || !child.hasSize) {
return;
}
// A child stretched into the overscroll area is larger than the
// scrollExtent, so for reversed axis directions it must be anchored by its
// actual size to keep its leading edge glued to the viewport's edge.
final childParentData = child.parentData! as SliverPhysicalParentData;
final Size childSize = child.size;
switch (applyGrowthDirectionToAxisDirection(
constraints.axisDirection,
constraints.growthDirection,
)) {
case AxisDirection.up:
childParentData.paintOffset = Offset(
0.0,
geometry.paintExtent + constraints.scrollOffset - childSize.height,
);
case AxisDirection.left:
childParentData.paintOffset = Offset(
geometry.paintExtent + constraints.scrollOffset - childSize.width,
0.0,
);
case AxisDirection.right:
case AxisDirection.down:
break;
}
}