prepareNumber function

List<String> prepareNumber(
  1. String num
)

Implementation

List<String> prepareNumber(String num) {
  String out = num;
  if (num.length % 3 == 1) {
    out = '00$out';
  } else if (num.length % 3 == 2) {
    out = '0$out';
  }

  RegExp exp = RegExp(r'\d{3}(?=\d)');
  return out.replaceAllMapped(exp, (match) => '${match.group(0)}*').split('*');
}