currencyToEmoji static method

String currencyToEmoji(
  1. Currency currency
)

Return Flag (Emoji Unicode) of a given currency

Implementation

static String currencyToEmoji(Currency currency) {
  final String currencyFlag = currency.flag!;
  // 0x41 is Letter A
  // 0x1F1E6 is Regional Indicator Symbol Letter A
  // Example :
  // firstLetter U => 20 + 0x1F1E6
  // secondLetter S => 18 + 0x1F1E6
  // See: https://en.wikipedia.org/wiki/Regional_Indicator_Symbol
  final int firstLetter = currencyFlag.codeUnitAt(0) - 0x41 + 0x1F1E6;
  final int secondLetter = currencyFlag.codeUnitAt(1) - 0x41 + 0x1F1E6;
  return String.fromCharCode(firstLetter) + String.fromCharCode(secondLetter);
}