It is common knowledge that typical floating point data types (aka float
and double
) are in Base 2, thus are bad for storing money because Base 2 numbers can not always accurately represent Base 10 numbers like money. To avoid this issue, languages such as Java have implemented data types such as BigDecimal. Is there any similar data type for Dart/Flutter?
As Abion47 said, the best way to store money would be to use the decimal package, which is like BigDecimal in Java and has a load of useful features.