withSpaces property

String get withSpaces

Returns this num parsed with spaces between thousands.

Implementation

String get withSpaces {
  if (this is double) {
    return toStringAsFixed(2);
  }

  String value = toString();

  int len = value.length;
  int thousand = 3;

  while (len > thousand) {
    value =
        '${value.substring(0, len - thousand)} ${value.substring(len - thousand, value.length)}';
    thousand += 4;
    len += 1;
  }

  return value;
}