convertToString static method

String convertToString(
  1. num value, {
  2. int decimalPlaces = 2,
})

Implementation

static String convertToString(num value, {int decimalPlaces = 2}) {
  if (value == value.toInt()) {
    return value.toInt().toString();
  } else {
    return value.toStringAsFixed(decimalPlaces);  // 保留指定的小数位数
  }
}