formatWithCommas static method

String formatWithCommas(
  1. int number
)

Format number with commas

number - The number to format Returns formatted number string

Implementation

static String formatWithCommas(int number) {
  final formatter = RegExp(r'(\d)(?=(\d{3})+(?!\d))');
  return number.toString().replaceAllMapped(formatter, (match) => '${match.group(1)},');
}