formatDouble method

String formatDouble()

Implementation

String formatDouble() {
  // Check if the value is an integer
  if (this == toInt()) {
    return toInt()
        .toString(); // Convert to integer and display without decimals
  } else {
    return toStringAsFixed(3).replaceFirst(
        RegExp(r'\.?0*$'), ''); // Display with up to 3 decimal places
  }
}