localToGlobal method

  1. @override
Offset localToGlobal(
  1. Offset point,
  2. RenderView view
)
override

Convert the given point from the local coordinate space to the global coordinate space of the RenderView.

This method operates in logical pixels for both coordinate spaces. It does not apply the device pixel ratio to translate to physical pixels.

For definitions for coordinate spaces, see TestWidgetsFlutterBinding.

Implementation

@override
Offset localToGlobal(Offset point, RenderView view) {
  // The method is expected to translate the given point expressed in logical
  // pixels in the local coordinate space to the global coordinate space (also
  // expressed in logical pixels).
  // The transform translates from the local coordinate space in logical
  // pixels to the global coordinate space in physical pixels.
  final Matrix4 transform = view.configuration.toMatrix();
  final Offset pointInPhysicalPixels = MatrixUtils.transformPoint(transform, point);
  // We need to apply the device pixel ratio to get back to logical pixels.
  return pointInPhysicalPixels / view.configuration.devicePixelRatio;
}