bigIntToString static method

String bigIntToString(
  1. BigInt? value, {
  2. bool withComma = false,
})

Implementation

static String bigIntToString(BigInt? value, {bool withComma = false}) {
  if (value == null) return '';
  final str = value.toString();
  if (!withComma) return str;

  final buffer = StringBuffer();
  int count = 0;
  for (int i = str.length - 1; i >= 0; i--) {
    buffer.write(str[i]);
    count++;
    if (count % 3 == 0 && i != 0) buffer.write(',');
  }
  return buffer.toString().split('').reversed.join('');
}