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;
|
||||
|
||||
// Convert input to base unit if needed
|
||||
if (_selectedUnits[input.name] != input.magnitude) {
|
||||
inputValues[input.name] = widget.corpus.convert(
|
||||
value,
|
||||
_selectedUnits[input.name]!,
|
||||
input.magnitude,
|
||||
);
|
||||
} else {
|
||||
inputValues[input.name] = value;
|
||||
}
|
||||
// Always convert from dropdown unit to variable's base unit
|
||||
inputValues[input.name] = widget.corpus.convert(
|
||||
value,
|
||||
_selectedUnits[input.name]!,
|
||||
input.magnitude,
|
||||
);
|
||||
}
|
||||
|
||||
final evaluator = FormulaEvaluator();
|
||||
|
|
|
|||
Loading…
Reference in a new issue