initScreenAwareSizes static method
initialize sizes Should be called only once
Implementation
static void initScreenAwareSizes(
BuildContext context, {
Size designSize = _defaultSize,
}) {
if (initialized) {
appLogsNS('Sizes already initialized');
printScreenInformation();
return;
}
initialized = true;
screenWidth = context.sizeX.width;
screenHeight = context.sizeX.height;
if (screenWidth > 300 && screenWidth < 500) {
defaultScreenWidth = 450;
defaultScreenHeight = defaultScreenWidth * screenHeight / screenWidth;
} else if (screenWidth > 500 && screenWidth < 600) {
defaultScreenWidth = 500;
defaultScreenHeight = defaultScreenWidth * screenHeight / screenWidth;
} else if (screenWidth > 600 && screenWidth < 700) {
defaultScreenWidth = 550;
defaultScreenHeight = defaultScreenWidth * screenHeight / screenWidth;
} else if (screenWidth > 700 && screenWidth < 1050) {
defaultScreenWidth = 800;
defaultScreenHeight = defaultScreenWidth * screenHeight / screenWidth;
} else {
defaultScreenWidth = screenWidth;
defaultScreenHeight = screenHeight;
}
ScreenUtil.init(
context,
designSize: Size(defaultScreenWidth, defaultScreenHeight),
);
printScreenInformation();
}