roundingNum static method

String roundingNum(
  1. double num,
  2. int fractionDigits
)

取消四舍五入 ignore: unused_element

Implementation

static String roundingNum(double num, int fractionDigits) {
  if ((num.toString().length - num.toString().lastIndexOf(".") - 1) < fractionDigits) {
    //小数点后有几位小数
    return num.toStringAsFixed(fractionDigits).substring(0, num.toString().lastIndexOf(".") + fractionDigits + 1).toString();
  } else {
    return num.toString().substring(0, num.toString().lastIndexOf(".") + fractionDigits + 1).toString();
  }
}