roundTo method

double roundTo(
  1. int decimals
)

Rounds this double to a specified number of decimal places.

Example:

double value = 3.14159;
double rounded = value.roundTo(2); // 3.14

Implementation

double roundTo(int decimals) {
  final multiplier = _powerOf10(decimals);
  return (this * multiplier).round() / multiplier;
}