35 lines
1.1 KiB
Dart
35 lines
1.1 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
class SizeConfig {
|
|
static late MediaQueryData _mediaQueryData;
|
|
static late double screenWidth;
|
|
static late double screenHeight;
|
|
static double? defaultSize;
|
|
static Orientation? orientation;
|
|
static double? blockHorizontal;
|
|
static double? blockVertical;
|
|
|
|
void init(BuildContext context) {
|
|
_mediaQueryData = MediaQuery.of(context);
|
|
screenWidth = _mediaQueryData.size.width;
|
|
screenHeight = _mediaQueryData.size.height;
|
|
orientation = _mediaQueryData.orientation;
|
|
blockHorizontal = screenWidth / 100;
|
|
blockVertical = screenHeight / 100;
|
|
}
|
|
}
|
|
|
|
// Get the proportionate height as per screen size
|
|
double getProportionateScreenHeight(double inputHeight) {
|
|
double screenHeight = SizeConfig.screenHeight;
|
|
// 640 is the layout height that designer use
|
|
return (inputHeight / 640.0) * screenHeight;
|
|
}
|
|
|
|
// Get the proportionate height as per screen size
|
|
double getProportionateScreenWidth(double inputWidth) {
|
|
double screenWidth = SizeConfig.screenWidth;
|
|
// 360 is the layout width that designer use
|
|
return (inputWidth / 360.0) * screenWidth;
|
|
}
|