withCommas property

String get withCommas

Groups the whole part with commas, decimals untouched. 1234567.8 → "1,234,567.8"

Implementation

String get withCommas {
  final String text = toString();
  final int dot = text.indexOf(".");
  final String whole = dot < 0 ? text : text.substring(0, dot);
  return "${whole.separateNumbers3By3()}${dot < 0 ? "" : text.substring(dot)}";
}