getEffectiveTransform method

Matrix4 getEffectiveTransform()

Implementation

Matrix4 getEffectiveTransform() {
  final Matrix4 result = Matrix4.identity();
  Offset transformOffset = renderStyle.transformOffset;
  Alignment transformAlignment = renderStyle.transformAlignment;
  result.translate(transformOffset.dx, transformOffset.dy);
  late Offset translation;
  if (transformAlignment != Alignment.topLeft) {
    // Use boxSize instead of size to avoid Flutter cannot access size beyond parent access warning
    translation =
        hasSize ? transformAlignment.alongSize(boxSize!) : Offset.zero;
    result.translate(translation.dx, translation.dy);
  }

  Matrix4? transformMatrix = renderStyle.transformMatrix;
  if (transformMatrix != null) {
    result.multiply(renderStyle.transformMatrix!);
  }

  if (transformAlignment != Alignment.topLeft)
    result.translate(-translation.dx, -translation.dy);
  result.translate(-transformOffset.dx, -transformOffset.dy);
  return result;
}