init static method

Future<void> init({
  1. double designWidth = 375,
  2. double standardWidth = 750,
})

Implementation

static Future<void> init({
  double designWidth = 375,
  double standardWidth = 750,
}) {
  _designWidth = designWidth;
  _standardWidth = standardWidth;
  final Completer completer = Completer();
  // https://www.jianshu.com/p/4f0651241956
  if (window.physicalSize.isEmpty) {
    window.onMetricsChanged = () {
      if (!window.physicalSize.isEmpty) {
        window.onMetricsChanged = null;
        _setup();
        completer.complete();
      }
    };
  } else {
    _setup();
    completer.complete();
  }
  return completer.future;
}