Skip to content

Instantly share code, notes, and snippets.

@BurakDizlek
BurakDizlek / CountryFlags.java
Last active December 31, 2024 00:23
Get to flag unicode as String and use it anywhere.
public class CountryFlags {
private static String A = getEmojiByUnicode(0x1F1E6);
private static String B = getEmojiByUnicode(0x1F1E7);
private static String C = getEmojiByUnicode(0x1F1E8);
private static String D = getEmojiByUnicode(0x1F1E9);
private static String E = getEmojiByUnicode(0x1F1EA);
private static String F = getEmojiByUnicode(0x1F1EB);
private static String G = getEmojiByUnicode(0x1F1EC);
private static String H = getEmojiByUnicode(0x1F1ED);
private static String I = getEmojiByUnicode(0x1F1EE);
@horgag
horgag / country flag
Created April 18, 2020 08:32
method for country flags
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);
};