formatCurrency function

String? formatCurrency({
  1. double? value,
  2. Decimal? decimalValue,
})

Implementation

String? formatCurrency({double? value, Decimal? decimalValue}) {
  if (value == null && decimalValue == null) {
    return null;
  }
  if (decimalValue != null) {
    value = decimalValue.toDouble();
  }
  return NumberFormat.currency(locale: 'pt_BR', symbol: 'R\$').format(value);
}