double_extensions.dart 207 Bytes Raw Blame History Permalink 1 2 3 4 5 6 7 8 import 'dart:math'; extension Precision on double { double toPrecision(int fractionDigits) { double mod = pow(10, fractionDigits.toDouble()); return ((this * mod).round().toDouble() / mod); } }