rupiah function Null safety

String rupiah(
  1. dynamic value,
  2. {String separator = '.',
  3. String trailing = ''}
)

Convert value to "Rp XX.XXX.XXX" as String

Implementation

String rupiah(value, {String separator = '.', String trailing = ''}) {
  return "Rp " +
      value.toString().replaceAllMapped(
          new RegExp(r'(\d{1,3})(?=(\d{3})+(?!\d))'),
          (Match m) => '${m[1]}${separator}') +
      trailing;
}