getCurrencyWithDecimal method

String getCurrencyWithDecimal(
  1. double amount, {
  2. bool withoutRp = false,
})

Implementation

String getCurrencyWithDecimal(double amount, {bool withoutRp = false}) {
  var myFormat = new NumberFormat("#,##0.00", "ind");
  var result = myFormat.format(amount);
  if (result.endsWith(",00"))
    result = result.substring(0, result.length - 3);
  else if (result.endsWith("0"))
    result = result.substring(0, result.length - 1);

  if (withoutRp) return result;
  return "Rp. " + result;
}