screenDestinationRect static method

Rect screenDestinationRect(
  1. DeviceInfo device,
  2. Orientation orientation
)

Implementation

static Rect screenDestinationRect(
  DeviceInfo device,
  Orientation orientation,
) {
  final destinationRect = globalDestinationRect(device, orientation);
  final frameSize = device.frameSizeOn(orientation);
  final scaleX = destinationRect.width / frameSize.width;
  final scaleY = destinationRect.height / frameSize.height;

  var screenBounds = device.screenPath.getBounds();
  if (orientation == Orientation.landscape) {
    screenBounds =
        Offset(
          device.frameSize.height - screenBounds.bottom,
          screenBounds.left,
        ) &
        screenBounds.size.flipped;
  }
  return (destinationRect.topLeft +
          Offset(screenBounds.left * scaleX, screenBounds.top * scaleY)) &
      Size(screenBounds.width * scaleX, screenBounds.height * scaleY);
}