currencyToEmoji function

String currencyToEmoji(
  1. String currencyFlagCode
)

Implementation

String currencyToEmoji(String currencyFlagCode) {
  // currencyFlagCode: United Knidom => GB, Sri Lanka => LK, likewise...
  // See more flagCodes in currency_picker flutter package

  // 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 = currencyFlagCode.codeUnitAt(0) - 0x41 + 0x1F1E6;
  final int secondLetter = currencyFlagCode.codeUnitAt(1) - 0x41 + 0x1F1E6;
  return String.fromCharCode(firstLetter) + String.fromCharCode(secondLetter);
}