init static method

void init({
  1. double designWidth = defaultWidth,
  2. double designHeight = defaultHeight,
  3. bool allowFontScaling = false,
  4. double defaultFontSize = 16,
})

Implementation

static void init({
  double designWidth = defaultWidth,
  double designHeight = defaultHeight,
  bool allowFontScaling = false,
  double defaultFontSize = 16,
}) {
  if (_instance == null) {
    _instance = ResponsiveSize._();
  }
  _instance!.desingWidthPx = designWidth;
  _instance!.designHeightPx = designHeight;
  _instance!.allowFontScaling = allowFontScaling;
  _instance!.defaultFontSize = defaultFontSize;
  _pixelRatio = window.devicePixelRatio;
  _screenWidth = window.physicalSize.width;
  _screenHeight = window.physicalSize.height;
  _widthBlock = screenWidth / 100;
  _heightBlock = screenHeight / 100;
  _statusBarHeight = window.padding.top;
  _bottomBarHeight = window.padding.bottom;
  _textScaleFactor = window.textScaleFactor;
  _spBlock = _instance!.setSp(_instance!.defaultFontSize) as double;
}