mediaQuery static method
MediaQueryData
mediaQuery({
- required BuildContext context,
- required DeviceInfo? info,
- required Orientation orientation,
Creates a MediaQuery from the given device info
, and for the current device orientation
.
All properties that are not simulated are inherited from the current context
's inherited MediaQuery.
Implementation
static MediaQueryData mediaQuery({
required BuildContext context,
required DeviceInfo? info,
required Orientation orientation,
}) {
final mediaQuery = MediaQuery.of(context);
final isRotated = info?.isLandscape(orientation) ?? false;
final viewPadding = 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: viewPadding,
viewInsets: EdgeInsets.zero,
viewPadding: viewPadding,
devicePixelRatio: info?.pixelRatio ?? mediaQuery.devicePixelRatio,
);
}