init method
Initializes the ScallingConfig with BuildContext to retrieve screen dimensions and platform information.
This method should be called at the beginning of your application or when the screen dimensions change.
Implementation
void init(BuildContext context) {
_mediaQueryData = MediaQuery.of(context);
screenHeight = _mediaQueryData?.size.height;
screenWidth = _mediaQueryData?.size.width;
platform = Theme.of(context).platform;
isMobile =
(platform == TargetPlatform.android) || (platform == TargetPlatform.iOS)
? true
: false;
if (screenWidth! < screenHeight!) {
shortDimension = screenWidth;
longDimension = screenHeight;
} else {
shortDimension = screenHeight;
longDimension = screenWidth;
}
switch (platform) {
/// Check for big size of screen devices
case (TargetPlatform.macOS || TargetPlatform.windows):
guidelineBaseWidth = 600;
guidelineBaseHeight = 1200;
break;
default:
/// for mobile devices
guidelineBaseWidth = 350;
guidelineBaseHeight = 680;
}
}