ScreenScaleProperties constructor
ScreenScaleProperties({})
Implementation
factory ScreenScaleProperties({
double? width,
double? height,
bool? allowFontScaling,
bool? allowSubpixel,
double? maxWidth,
}) {
if (maxWidth == null &&
width == null &&
height == null &&
allowFontScaling == null) {
return ScreenScale;
}
final pixelRatio = WidgetsBinding.instance!.window.devicePixelRatio;
final physicalWidth = WidgetsBinding.instance!.window.physicalSize.width;
var widthCalc = maxWidth != null
? math.min(maxWidth * pixelRatio, physicalWidth)
: physicalWidth;
return _instance = ScreenScaleProperties._(
uiWidthPx: width ??
WidgetsBinding.instance!.window.physicalSize.width / pixelRatio,
uiHeightPx: height ??
(WidgetsBinding.instance!.window.physicalSize.height / pixelRatio),
allowFontScaling: allowFontScaling ?? false,
allowSubpixel: allowSubpixel ?? allowFontScaling ?? false,
pixelRatio: WidgetsBinding.instance!.window.devicePixelRatio,
screenWidth: widthCalc,
screenHeight: WidgetsBinding.instance!.window.physicalSize.height,
statusBarHeight: WidgetsBinding.instance!.window.padding.top,
bottomBarHeight: WidgetsBinding.instance!.window.padding.bottom,
textScaleFactor: WidgetsBinding.instance!.window.textScaleFactor,
);
}