Answers for "flutter round duble to two decimal places"

2

double 2 decimal places flutter

/// Define an extension:
extension Ex on double {
  double toPrecision(int n) => double.parse(toStringAsFixed(n));
}

/// Usage:
void main() {
  double d = 2.3456789;
  double d1 = d.toPrecision(1); // 2.3
  double d2 = d.toPrecision(2); // 2.35
  double d3 = d.toPrecision(3); // 2.345
}
Posted by: Guest on January-14-2021
0

flutter round up double

int doubleRoundUp = doubleToRoundUp.ceil();
Posted by: Guest on January-14-2021

Code answers related to "flutter round duble to two decimal places"

Browse Popular Code Answers by Language