# getInstance static method

Currency getInstance(

1. String currencyCode

)

Abstract base class for currency operations following ISO 4217 standards.

This class provides a common interface for all currency types and includes static methods to manage and retrieve currency instances according to ISO 4217 codes or locale information.

Use this class to:

- Retrieve currency instances by code or locale.
- Access currency metadata such as symbol, numeric code, or display name.
- Work with all available currencies in a consistent manner.

Example usage:

    // Get a currency by ISO code
    final usd = Currency.getInstance('USD');

    // Get a currency by locale
    final eur = Currency.getInstanceFromLocale(Locale('de', 'DE'));

    // List all available currencies
    final allCurrencies = Currency.getAllCurrencies();

    // Access currency properties
    print(usd.symbol); // $
    print(eur.displayName); // Euro

Returns a Currency instance for the given ISO 4217 currency code.

Throws UnsupportedOperationException if the currency code is invalid or unsupported.

Example:

    final usd = Currency.getInstance('USD');
    final eur = Currency.getInstance('EUR');

## Implementation

    static Currency getInstance(String currencyCode) {
      if (currencyCode.isEmpty) {
        throw UnsupportedOperationException('Currency code cannot be empty');
      }

      final upperCode = currencyCode.toUpperCase();

      if (_currencyCache.containsKey(upperCode)) {
        return _currencyCache[upperCode]!;
      }

      final data = CurrencyDatabase.getCurrencyData(upperCode);
      if (data == null) {
        throw UnsupportedOperationException('Unsupported currency code: $currencyCode');
      }

      final currency = _Currency(
        currencyCode: upperCode,
        symbol: data['symbol'] as String,
        defaultFractionDigits: data['digits'] as int,
        numericCode: data['numeric'] as int,
        displayName: data['name'] as String,
      );

      _currencyCache[upperCode] = currency;
      return currency;
    }