roundToNearestMultiple method

double roundToNearestMultiple(
  1. double multiple
)

Rounds this double to the nearest multiple of multiple.

Throws ArgumentError if multiple is zero.

Implementation

double roundToNearestMultiple(double multiple) {
  if (multiple == 0) {
    throw ArgumentError('Multiple cannot be zero.');
  }
  return (this / multiple).round() * multiple;
}