fix: convert input variables from dropdown to base unit in formula evaluation
Co-authored-by: aider (openrouter/deepseek/deepseek-r1:free) <aider@aider.chat>
This commit is contained in:
parent
d3c509ace4
commit
f52e5debcb
1 changed files with 6 additions and 9 deletions
|
|
@ -58,15 +58,12 @@ class _FormulaScreenState extends State<FormulaScreen> {
|
||||||
final value = double.tryParse(_inputControllers[input.name]!.text) ?? 0.0;
|
final value = double.tryParse(_inputControllers[input.name]!.text) ?? 0.0;
|
||||||
|
|
||||||
// Convert input to base unit if needed
|
// Convert input to base unit if needed
|
||||||
if (_selectedUnits[input.name] != input.magnitude) {
|
// Always convert from dropdown unit to variable's base unit
|
||||||
inputValues[input.name] = widget.corpus.convert(
|
inputValues[input.name] = widget.corpus.convert(
|
||||||
value,
|
value,
|
||||||
_selectedUnits[input.name]!,
|
_selectedUnits[input.name]!,
|
||||||
input.magnitude,
|
input.magnitude,
|
||||||
);
|
);
|
||||||
} else {
|
|
||||||
inputValues[input.name] = value;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
final evaluator = FormulaEvaluator();
|
final evaluator = FormulaEvaluator();
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue