roundTo method
Rounds the numeric value to digits decimal places.
Example:
price.roundTo(2); // 3.14159 => 3.14
Implementation
void roundTo(int digits) {
final factor = math.pow(10, digits);
value = (value * factor).round() / factor;
}
Rounds the numeric value to digits decimal places.
Example:
price.roundTo(2); // 3.14159 => 3.14
void roundTo(int digits) {
final factor = math.pow(10, digits);
value = (value * factor).round() / factor;
}