signedRoundToNDecimals function

String signedRoundToNDecimals(
  1. double aArrondir, {
  2. int nbDecimales = 2,
})

Provide a plus or a minus sign, and round a double input aArrondir to nbDecimales decimals (if not provided, 2 decimals)

Implementation

String signedRoundToNDecimals(double aArrondir, {int nbDecimales = 2}) {
  var tempValue = (aArrondir * math.pow(10, nbDecimales.toDouble())).round();
  double toSign = tempValue / math.pow(10, nbDecimales.toDouble());
  return (toSign > 0 ? "+" + toSign.toString() : toSign.toString());
}