mediaQuery static method

MediaQueryData mediaQuery(
  1. BuildContext context,
  2. DeviceInfo? info,
  3. Orientation orientation
)

Implementation

static MediaQueryData mediaQuery(
    BuildContext context, DeviceInfo? info, Orientation orientation) {
  final mediaQuery = MediaQuery.of(context);
  final isRotated = DeviceFrame.isRotated(info, orientation);
  final padding = isRotated
      ? (info?.rotatedSafeAreas ?? info?.safeAreas)
      : (info?.safeAreas ?? mediaQuery.padding);

  final screenSize = info != null ? info.screenSize : mediaQuery.size;
  final width = isRotated ? screenSize.height : screenSize.width;
  final height = isRotated ? screenSize.width : screenSize.height;

  return mediaQuery.copyWith(
    size: Size(width, height),
    padding: padding,
    viewInsets: EdgeInsets.zero,
    viewPadding: padding,
    devicePixelRatio: info?.pixelRatio ?? mediaQuery.devicePixelRatio,
  );
}