Dimensions constructor

Dimensions({
  1. required BuildContext context,
  2. double? width,
  3. double? height,
})

Implementation

Dimensions({required BuildContext context,double? width,double? height}){

  _mediaQueryData = MediaQuery.of(context);
  if(width == null || height == null){

    screenWidth = _mediaQueryData.size.width;
    screenHeight = _mediaQueryData.size.height;
    devicePixelRatio = _mediaQueryData.devicePixelRatio;
  }else{
    screenWidth = width;
    screenHeight = height;
  }

  screenWidth = kIsWeb ? (screenWidth! - 80) : screenWidth;

  _safeAreaHorizontal = _mediaQueryData.padding.left +
      _mediaQueryData.padding.right;
  _safeAreaVertical = _mediaQueryData.padding.top +
      _mediaQueryData.padding.bottom;
  safeBlockHorizontal = (screenWidth! - _safeAreaHorizontal!) / 100;
  safeBlockVertical = (screenHeight! -
      _safeAreaVertical) / 100;



  fontH1 = (screenWidth! >= 500 ? screenHeight! / 2 : screenWidth)! / 18.7;  // 24
  fontH2 = (screenWidth! >= 500 ? screenHeight! / 2 : screenWidth)! / 20.4;  // 22
  font20 = (screenWidth! >= 500 ? screenHeight! / 2 : screenWidth)! / 22.45; // 20
  fontH3 = (screenWidth! >= 500 ? screenHeight! / 2 : screenWidth)! / 25;    //18
  fontH4 = (screenWidth! >= 500 ? screenHeight! / 2 : screenWidth)! / 28;  // 16
  fontH5 = (screenWidth! >= 500 ? screenHeight! / 2 : screenWidth)! / 32;  //14
  font13 = (screenWidth! >= 500 ? screenHeight! / 2 : screenWidth)! / 34.5;  //13
  fontH6 = (screenWidth! >= 500 ? screenHeight! / 2 : screenWidth)! / 37.4;  //12
}