valueFor static method
double
valueFor(
- AppDimensContextLike scope,
- double base,
- StrategyFormula formula,
- DpQualifier qualifier, {
- Inverter inverter = Inverter.standard,
- bool ignoreMultiWindows = false,
- bool applyAspectRatio = false,
- double? customSensitivityK,
- CalcType calcType = CalcType.auto,
- ValueType valueType = ValueType.dp,
Explicit-context variant (full engine path, cached when eligible).
Implementation
static double valueFor(
AppDimensContextLike scope,
double base,
StrategyFormula formula,
DpQualifier qualifier, {
Inverter inverter = Inverter.standard,
bool ignoreMultiWindows = false,
bool applyAspectRatio = false,
double? customSensitivityK,
CalcType calcType = CalcType.auto,
ValueType valueType = ValueType.dp,
}) {
final configuration = scope.configuration;
final key = CacheKey(
baseValue: base,
isLandscape: configuration.isLandscape,
ignoreMultiWindows: ignoreMultiWindows,
calcType: calcType,
qualifier: qualifier,
inverter: inverter,
applyAspectRatio: applyAspectRatio,
valueType: valueType,
customSensitivityK: customSensitivityK,
);
final metrics = scope.dimenMetrics;
return DimenCache.getOrPutFor(metrics, key, () {
if (ignoreMultiWindows && metrics.isInMultiWindowMode) {
return _unitConvert(base, metrics, valueType);
}
final effectiveQ = DimenCalculationPlumbing.effectiveQualifier(
qualifier,
inverter,
configuration.isLandscape,
configuration.isPortrait,
);
final computed = formula(
base, metrics, effectiveQ, applyAspectRatio, customSensitivityK);
return _unitConvertSp(computed, metrics, valueType);
});
}