init method

void init(
  1. BuildContext context, {
  2. double? height,
  3. double? width,
})

Implementation

void init(
  BuildContext context, {
  double? height,
  double? width,
}) {
  _mediaQueryData = MediaQuery.of(context);
  screenWidth = _mediaQueryData.size.width;
  screenHeight = _mediaQueryData.size.height;
  refHeight = height ?? 812;
  refWidth = width ?? 375;

  deviceTextFactor = _mediaQueryData.textScaler.scale(20) / 20;

  if (screenHeight < 1200) {
    blockSizeHorizontal = screenWidth / 100;
    blockSizeVertical = screenHeight / 100;

    _safeAreaHorizontal =
        _mediaQueryData.padding.left + _mediaQueryData.padding.right;
    _safeAreaVertical =
        _mediaQueryData.padding.top + _mediaQueryData.padding.bottom;
    safeBlockHorizontal = (screenWidth - _safeAreaHorizontal) / 100;
    safeBlockVertical = (screenHeight - _safeAreaVertical) / 100;
  } else {
    blockSizeHorizontal = screenWidth / 120;
    blockSizeVertical = screenHeight / 120;

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