anchorTransformRelativeTo function

Matrix4 anchorTransformRelativeTo(
  1. RenderBox anchorBox,
  2. RenderObject source
)

Computes the transform from anchorBox's local coordinate space into source's local coordinate space, for two render objects that aren't necessarily ancestor/descendant of each other.

Implementation

Matrix4 anchorTransformRelativeTo(RenderBox anchorBox, RenderObject source) {
  final Matrix4 anchorToGlobal = anchorBox.getTransformTo(null);
  final Matrix4 sourceToGlobal = source.getTransformTo(null);
  final Matrix4 globalToSource = Matrix4.copy(sourceToGlobal)..invert();
  return globalToSource.multiplied(anchorToGlobal);
}