round static method

double round(
  1. double value, {
  2. int precision = 2,
})

Standard rounding (rounds halves away from zero).

1.5 → 2, 2.5 → 3, -1.5 → -2

Implementation

static double round(double value, {int precision = 2}) {
  final factor = math.pow(10, precision);
  return (value * factor).roundToDouble() / factor;
}