configure static method

void configure({
  1. MediaQueryData? data,
  2. Size? designSize,
  3. bool? splitScreenMode,
  4. bool? minTextAdapt,
  5. FontSizeResolver? fontSizeResolver,
})

Implementation

static void configure({
  MediaQueryData? data,
  Size? designSize,
  bool? splitScreenMode,
  bool? minTextAdapt,
  FontSizeResolver? fontSizeResolver,
}) {
  try {
    if (data != null)
      _instance._data = data;
    else
      data = _instance._data;

    if (designSize != null)
      _instance._uiSize = designSize;
    else
      designSize = _instance._uiSize;
  } catch (_) {
    throw Exception(
        'You must either use ScreenUtil.init or ScreenUtilInit first');
  }

  final MediaQueryData? deviceData = data.nonEmptySizeOrNull();
  final Size deviceSize = deviceData?.size ?? designSize;

  final orientation = deviceData?.orientation ??
      (deviceSize.width > deviceSize.height
          ? Orientation.landscape
          : Orientation.portrait);

  _instance
    ..fontSizeResolver = fontSizeResolver ?? _instance.fontSizeResolver
    .._minTextAdapt = minTextAdapt ?? _instance._minTextAdapt
    .._splitScreenMode = splitScreenMode ?? _instance._splitScreenMode
    .._orientation = orientation;

  _instance._elementsToRebuild?.forEach((el) => el.markNeedsBuild());
}