formatCurrency static method

String formatCurrency(
  1. double amount
)

Formats a numeric amount as currency in USD (default locale: en_US, symbol: $). You can customize the locale and symbol if needed.

Implementation

static String formatCurrency(double amount) {
  return NumberFormat.currency(locale: 'en_US', symbol: '\$').format(amount);
  // Customize the currency locale and symbol as needed.
}