This is due to floating point math. This behavior is common in many languages. If you want to know more about this I recommend this site. Some languages like Java have classes made to work with this type of precise operation, however Dart does not have official support for this, luckily to get around this problem there is a package one. I'll show you what worked for me here. Using your code would look like this:
First of all to solve the main problem we must use a package called decimal, add the following dependency in your pubspec.yaml and update the packages:
name: ...
dependencies:
decimal: ^0.3.5
...
Then your file will look like this:
import 'package:decimal/decimal.dart';
void main() {
List<double> list = [1.0, 1.0, 1.0, 1.0, 0.8, 52.9];
double total = list.fold(0, (total, value) {
var result = Decimal.parse(total.toString()) + Decimal.parse(value.toString());
return double.parse(result.toString());
});
print(total); // 57.7
}
Obs: I used the google translator.