currency static method

String currency(
  1. double amount, {
  2. bool? showSymbol,
  3. bool? showDecimals,
  4. String? unitSymbol,
})

Formats currency values (defaulting to the en_LK locale, e.g. Rs. 1,000.00).

Implementation

static String currency(double amount, {bool? showSymbol, bool? showDecimals, String? unitSymbol}) {
  final symbol = showSymbol == false ? '' : TFormats.currentCurrencySymbol;
  final hasDecimal = amount % 1 != 0;
  final decimalDigits = showDecimals == true || hasDecimal ? 2 : 0;

  return NumberFormat.currency(locale: 'en_LK', symbol: symbol, decimalDigits: decimalDigits).format(amount) +
      (unitSymbol != null ? ' / $unitSymbol' : '');
}