getShortAmount method

String getShortAmount(
  1. int amount, {
  2. String? textMany,
  3. String? textExtra,
})

Implementation

String getShortAmount(int amount, {String? textMany, String? textExtra}) {
  var result = "";
  if (amount < 1000)
    result = amount.toString();
  else if (amount < 1000000) {
    var currency = getCurrency(amount, withoutRp: true);
    result = currency.substring(0, currency.indexOf(".")) + " K";
  } else if (amount < 1000000000) {
    var currency = getCurrency(amount, withoutRp: true);
    result = currency.substring(0, currency.indexOf(".")) + " M";
  }

  if (result.isNotEmpty) {
    if (textExtra != null) return result += " $textExtra";
    return result;
  }
  return textMany ?? "many";
}