toPrecision method

double toPrecision(
  1. int fractionDigits
)

Implementation

double toPrecision(int fractionDigits) {
  var mod = pow(10, fractionDigits.toDouble()).toDouble();
  return ((this * mod).round().toDouble() / mod);
}