formatWithCommasHelper function

String formatWithCommasHelper(
  1. String num
)

Implementation

String formatWithCommasHelper(String num) {
  RegExp exp = RegExp(r'(\d)(?=(\d{3})+(?!\d))');
  return num.replaceAllMapped(exp, (Match match) => '${match.group(1)},');
}