0
Gentlemen, good night!
I have a problem in my calculation because it is coming out broken values, Ex: 13,3434
I would like you to leave only 13,34.
Follow the code for better viewing.
Future calculate() {
double precototal1 =
double.parse(_precoCtrl.text.replaceAll(new RegExp(r'[,.]'), '')) * 12;
double precototal2 =
double.parse(_precoCtrl1.text.replaceAll(new RegExp(r'[,.]'), '')) * 12;
double unidademl1 =
double.parse(_unitCtrl.text.replaceAll(new RegExp(r'[,.]'), ''));
double unidademl2 =
double.parse(_unitCtrl1.text.replaceAll(new RegExp(r'[,.]'), ''));
double difvalor = 0;
double latas = 0;
double litros = 0;
double totlitros = 0;
double diflitros = 0;
setState(() {
_completed = false;
_busy = true;
});
return new Future.delayed(const Duration(seconds: 1), () {
setState(
() {
print(formatter.format(precototal2));
if (precototal1 > precototal2) {
difvalor = precototal1 - precototal2;
latas = (difvalor / precototal2);
litros = (latas * unidademl2);
totlitros = litros + unidademl2;
diflitros = (totlitros - unidademl1);
} else {
difvalor = (precototal2 - precototal1);
latas = (difvalor + precototal1);
totlitros = litros + unidademl1;
litros = (latas / unidademl1);
diflitros = (unidademl2 - totlitros);
}
Exactly what I was looking for!!! Only in this case, as you can see in the code my double variables are only in the calculate and this is preventing to pass it with the toString
– Matheus Lima