formatAsIntOrDouble function

String formatAsIntOrDouble(
  1. double? str
)

This method remove the decimals if the value doesn't have decimals

Implementation

String formatAsIntOrDouble(double? str) {
  final values = str.toString().split(".");
  if (values.length > 1) {
    final int intDecimal = int.parse(values[1]);
    if (intDecimal == 0) {
      return str!.toInt().toString();
    }
  }
  return str.toString();
}