valueFor static method

double valueFor(
  1. AppDimensContextLike scope,
  2. double base,
  3. StrategyFormula formula,
  4. DpQualifier qualifier, {
  5. Inverter inverter = Inverter.standard,
  6. bool ignoreMultiWindows = false,
  7. bool applyAspectRatio = false,
  8. double? customSensitivityK,
  9. CalcType calcType = CalcType.auto,
  10. 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);
  });
}