localToGlobal static method

Offset? localToGlobal({
  1. required BuildContext context,
  2. required Offset point,
  3. BuildContext? ancestor,
})

Convert the given point from the local coordinate system for this context to the global coordinate system in logical pixels.

If ancestor is non-null, this function converts the given point to the coordinate system of ancestor (which must be an ancestor of this render object of context) instead of to the global coordinate system.

This method is implemented in terms of getTransformTo. If the transform matrix puts the given point on the line at infinity (for instance, when the transform matrix is the zero matrix), this method returns (NaN, NaN).

Implementation

static Offset? localToGlobal({
  required BuildContext context,
  required Offset point,
  BuildContext? ancestor,
}) {
  final renderObject = findRenderObject(context);
  if (renderObject == null) return null;
  return MatrixUtils.transformPoint(
    renderObject.getTransformTo(findRenderObject(ancestor)),
    point,
  );
}