applyPaintTransformForBoxChild method

  1. @protected
void applyPaintTransformForBoxChild(
  1. RenderBox child,
  2. Matrix4 transform

Utility function for applyPaintTransform for use when the children are RenderBox widgets.

This function turns the value returned by childMainAxisPosition and childCrossAxisPositionfor the child in question into a translation that it then applies to the given matrix.

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


void applyPaintTransformForBoxChild(RenderBox child, Matrix4 transform) {
  final bool rightWayUp = _getRightWayUp(constraints);
  double delta = childMainAxisPosition(child);
  final double crossAxisDelta = childCrossAxisPosition(child);
  switch (constraints.axis) {
    case Axis.horizontal:
      if (!rightWayUp) {
        delta = geometry!.paintExtent - child.size.width - delta;
      transform.translate(delta, crossAxisDelta);
    case Axis.vertical:
      if (!rightWayUp) {
        delta = geometry!.paintExtent - child.size.height - delta;
      transform.translate(crossAxisDelta, delta);