format method

  1. @override
String format(
  1. Decimal decimal
)
override

Implementation

@override
String format(Decimal decimal) {
  List<String> parts = decimal.doubleValue
      .toStringAsFixed(precision)
      .replaceAll('.', '')
      .split('')
      .reversed
      .toList(growable: true);

  int start = precision + 4;
  if (precision > 0) {
    parts.insert(precision, decimalSeparator);
  } else {
    start = 3;
  }

  for (int pos = start; parts.length > pos; pos += 4) {
    parts.insert(pos, thousandSeparator);
  }

  return parts.reversed.join();
}