error en conversor de temperaturas
This commit is contained in:
parent
0c4fef93c1
commit
a48182ffbf
3 changed files with 10 additions and 10 deletions
|
|
@ -61,6 +61,7 @@ class _FormulaScreenState extends State<FormulaScreen> {
|
|||
String? _result;
|
||||
String? _selectedOutputUnit;
|
||||
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
|
@ -106,15 +107,13 @@ class _FormulaScreenState extends State<FormulaScreen> {
|
|||
final result = evaluator.evaluate(widget.formula, inputValues);
|
||||
|
||||
// Convert output to selected unit if needed
|
||||
if (_selectedOutputUnit != widget.formula.output.unit) {
|
||||
_result = widget.corpus.convert(
|
||||
result,
|
||||
widget.formula.output.unit,
|
||||
_selectedOutputUnit!,
|
||||
).toStringAsFixed(2);
|
||||
} else {
|
||||
_result = result.toStringAsFixed(2);
|
||||
}
|
||||
_result = widget.corpus.convert(
|
||||
result,
|
||||
widget.formula.output.unit,
|
||||
_selectedOutputUnit!,
|
||||
).toStringAsFixed(2);
|
||||
|
||||
//print( "_evaluateFormula: result:${result} _result:${_result}");
|
||||
|
||||
setState(() {});
|
||||
} catch (e, stack) {
|
||||
|
|
|
|||
|
|
@ -131,6 +131,7 @@ class Corpus{
|
|||
final xBase = _convertToBase(x, fromUnit);
|
||||
final xTo = _convertFromBase(xBase, toUnit);
|
||||
|
||||
//print( "convert: x:${x}${fromUnit} xTo:${xTo}${toUnit}");
|
||||
return xTo;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
"name": "Temperature converter",
|
||||
"description": "Example of simple formula, just unit conversion",
|
||||
"input": [
|
||||
{"name": "Input", "unit": "Celsius" }
|
||||
{"name": "Input", "unit": "Kelvin" }
|
||||
],
|
||||
"output": {"name": "Output", "unit": "Kelvin" },
|
||||
"d4rtCode": "Output = Input;",
|
||||
|
|
|
|||
Loading…
Reference in a new issue