I have a problem with calculate with Double in Flutter.
This is my code:
double depth = 0.5;
RoundIconButton(
icon: FontAwesomeIcons.plus,
onPressed: () {
setState(() {
depth = depth + 0.1;
});
},
),
The Outcome comes in a textfield
Text(
depth.toString(),
style: kBigTextstyle,
),
When I push the plus button, it shows:
0.6
then 0.7
en then 079999999999999
But is has to be 0.8
depth = depth + 0.10000;
double depth = 0.5;
RoundIconButton(
icon: FontAwesomeIcons.plus,
onPressed: () {
setState(() {
depth = depth + 0.1;
});
},
),
The Outcome comes in a textfield
Text(
depth.toString(),
style: kBigTextstyle,
),
I expect the output of 0.7 + 0.1 to be 0.8 but the actual output is 0.7999999