getDollarFormat method

String getDollarFormat(
  1. double dollarString
)

Implementation

String getDollarFormat(double dollarString) {
  RegExp reg = new RegExp(r'(\d{1,3})(?=(\d{3})+(?!\d))');
  String Function(Match) mathFunc = (Match match) => '${match[1]},';

  return '\$${dollarString.toStringAsFixed(2).replaceAllMapped(reg, mathFunc)}';
}