init static method

void init(
  1. BuildContext context, {
  2. double? baseWidth,
  3. double? baseHeight,
})

Initialize ResponsiveConfig with the current screen size Optionally set base dimensions in the same call

Example:

// Option 1: Use default base dimensions
ResponsiveConfig.init(context);

// Option 2: Set custom base dimensions
ResponsiveConfig.init(context, baseWidth: 375, baseHeight: 812);

Implementation

static void init(
  BuildContext context, {
  double? baseWidth,
  double? baseHeight,
}) {
  // Set custom base dimensions if provided
  if (baseWidth != null) _baseWidth = baseWidth;
  if (baseHeight != null) _baseHeight = baseHeight;

  // Set current screen dimensions
  final size = MediaQuery.of(context).size;
  _size = size;
  _width = size.width;
  _height = size.height;
  _initialized = true;
}