toPrecision method
Returns this double value rounded to the specified number of decimal places.
fractionDigits
is the number of digits after the decimal point.
Implementation
double toPrecision(int fractionDigits) {
var mod = pow(10, fractionDigits.toDouble()).toDouble();
return ((this * mod).round().toDouble() / mod);
}