roundTo method

void roundTo(
  1. int digits
)

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;
}