abbrevKandM function

String abbrevKandM(
  1. num total
)

Implementation

String abbrevKandM(num total) {
  if (total > 999999) {
    if (total % 10000 == 0) {
      final rounded = (total / 1000000).roundTwoDecimals;
      if (rounded.toInt() == rounded) {
        return '${rounded.toInt()}M';
      }
      return '${rounded}M';
    }
  }
  if (total > 999 && total < 1000000) {
    if (total % 1000 == 0) {
      final rounded = (total / 1000).roundTwoDecimals;
      if (rounded.toInt() == rounded) {
        return '${rounded.toInt()}K';
      }
      return '${rounded}K';
    }
  }
  return total.toString();
}