resolveScaledSpValue static method
double
resolveScaledSpValue(
- double base,
- AppDimensContextLike scope,
- DpQualifier qualifier, {
- bool fontScale = true,
- Inverter inverter = Inverter.standard,
- bool ignoreMultiWindows = false,
- bool applyAspectRatio = false,
- double? customSensitivityK,
Scaled sp value (logical sp): with fontScale the framework applies the
system font scale at render; without it the value pre-divides by the
scale so rendering cancels it back.
Implementation
static double resolveScaledSpValue(
double base,
AppDimensContextLike scope,
DpQualifier qualifier, {
bool fontScale = true,
Inverter inverter = Inverter.standard,
bool ignoreMultiWindows = false,
bool applyAspectRatio = false,
double? customSensitivityK,
}) {
final configuration = scope.configuration;
final key = CacheKey(
baseValue: base,
isLandscape: configuration.isLandscape,
ignoreMultiWindows: ignoreMultiWindows,
calcType: CalcType.scaled,
qualifier: qualifier,
inverter: inverter,
applyAspectRatio: applyAspectRatio,
valueType: fontScale ? ValueType.spWithScale : ValueType.spNoScale,
customSensitivityK: customSensitivityK,
);
final metrics = scope.dimenMetrics;
return DimenCache.getOrPutFor(metrics, key, () {
final scaledDp = calculateScaledDp(
base,
configuration,
qualifier,
inverter,
ignoreMultiWindows,
applyAspectRatio,
customSensitivityK,
knownInMultiWindow: metrics.isInMultiWindowMode,
metrics: metrics,
);
if (fontScale) return scaledDp;
final fs = metrics.fontScale;
return fs > 0 ? scaledDp / fs : scaledDp;
});
}