Created
April 18, 2020 08:32
-
-
Save horgag/013f3c92ed2b8c9b1e3992bd740deb8d to your computer and use it in GitHub Desktop.
method for country flags
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void main() { | |
| const int flagOffset = 0x1F1E6; | |
| const int asciiOffset = 0x41; | |
| final codeToCountryEmoji = (code) { | |
| final char1 = code.codeUnitAt(0) - asciiOffset + flagOffset; | |
| final char2 = code.codeUnitAt(1) - asciiOffset + flagOffset; | |
| return String.fromCharCode(char1) + String.fromCharCode(char2); | |
| }; | |
| print(codeToCountryEmoji("IE")); | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment