toRupiah method

String toRupiah({
  1. bool usingSymbol = true,
})

Converts the numeric string to Indonesian Rupiah formatted string.

Example:

"15000".toRupiah(); // "Rp15.000"

Implementation

String toRupiah({bool usingSymbol = true}) {
  final value = toInt();
  if (value == null) return "";

  final formatter = NumberFormat.simpleCurrency(
    locale: 'id_ID',
    decimalDigits: 0,
  );
  final formatted = formatter.format(value);
  return usingSymbol ? formatted : formatted.replaceAll('Rp', '');
}