setDeviceData static method
void
setDeviceData(
- BuildContext context,
- BoxConstraints constraints,
- Orientation currentOrientation
Implementation
static void setDeviceData(
BuildContext context,
BoxConstraints constraints,
Orientation currentOrientation,
) {
final mediaQuery = MediaQuery.of(context);
final padding = mediaQuery.padding;
final viewPadding = mediaQuery.viewPadding;
// Sets boxconstraints and orientation
boxConstraints = constraints;
orientation = currentOrientation;
// Sets screen width and height
width = boxConstraints.maxWidth;
height = boxConstraints.maxHeight;
// Set safe area insets
safeAreaTop = padding.top;
safeAreaBottom = padding.bottom;
safeAreaLeft = padding.left;
safeAreaRight = padding.right;
// Set status bar and navigation bar heights
statusBarHeight = viewPadding.top;
navigationBarHeight = viewPadding.bottom;
// Calculate safe dimensions
heightSafe = height - safeAreaTop - safeAreaBottom;
widthSafe = width - safeAreaLeft - safeAreaRight;
// Set screen type and device type
deviceType = getDeviceType(defaultTargetPlatform);
screenType = getScreenType(mediaQuery);
// Sets aspect and pixel ratio
aspectRatio = constraints.constrainDimensions(width, height).aspectRatio;
pixelRatio = View.of(context).devicePixelRatio;
// Set text scale factor
final config = ResponsiveMasterConfig.instance;
double rawTextScale = mediaQuery.textScaleFactor;
if (config.respectTextScaleFactor) {
textScaleFactor = rawTextScale.clamp(
config.minTextScaleFactor,
config.maxTextScaleFactor,
);
} else {
textScaleFactor = 1.0;
}
// Set RTL mode
isRTL = Directionality.of(context) == TextDirection.rtl;
// Debug logging
if (config.debugMode) {
debugPrint('📱 ResponsiveMaster Device Data Updated:');
debugPrint(
' Screen: ${width.toStringAsFixed(1)} x ${height.toStringAsFixed(1)}');
debugPrint(
' Safe: ${widthSafe.toStringAsFixed(1)} x ${heightSafe.toStringAsFixed(1)}');
debugPrint(' Type: $screenType');
debugPrint(' Orientation: $orientation');
debugPrint(' Text Scale: ${textScaleFactor.toStringAsFixed(2)}');
debugPrint(' RTL: $isRTL');
}
}