format method

String format(
  1. double price,
  2. String currencyCode
)

Formats a price with currency symbol.

format(9.99, 'USD'); // '$9.99'
format(9990, 'KRW'); // '₩9,990'

Implementation

String format(double price, String currencyCode) {
  try {
    final format = NumberFormat.currency(
      locale: locale,
      symbol: _getCurrencySymbol(currencyCode),
      decimalDigits: _getDecimalDigits(currencyCode),
    );
    return format.format(price);
  } catch (_) {
    // Fallback to simple format
    return '${_getCurrencySymbol(currencyCode)}${price.toStringAsFixed(2)}';
  }
}