d method
Scales two values (representing a small-screen dimension) to the current screen diagonal.
Implementation
double d(BuildContext context) {
FlexiInheritedWidget.of(context, aspect: FlexiAspect.width);
final data = FlexiInheritedWidget.of(context, aspect: FlexiAspect.height);
if (data == null) throw Exception('FlexiConfig not found in context.');
double designWidthValue =
data.deviceTypeConfig.targetDeviceType == TargetDeviceType.mobilePortrait
? data.deviceTypeConfig.designMinWidth
: data.deviceTypeConfig.designMaxWidth;
double designHeightValue =
data.deviceTypeConfig.targetDeviceType == TargetDeviceType.mobilePortrait
? data.deviceTypeConfig.designMinHeight
: data.deviceTypeConfig.designMaxHeight;
double smallScreenDiagonal =
sqrt(pow(item1.toDouble(), 2) + pow(item2.toDouble(), 2));
double screenDiagonal =
sqrt(pow(data.screenWidth, 2) + pow(data.screenHeight, 2));
double screenDesignDiagonal =
sqrt(pow(designWidthValue, 2) + pow(designHeightValue, 2));
assert(screenDesignDiagonal > 0, 'Design diagonal must be greater than zero.');
return (smallScreenDiagonal * screenDiagonal) / max(1.0, screenDesignDiagonal);
}