Skip to content

Convert 🌍 Locale (languageCode, scriptCode and countryCode) to the corresponding 🏳️ Emoji Flag 🏴.

License

Notifications You must be signed in to change notification settings

MichaelDark/locale_emoji

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

15 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🏳️ Locale Emoji 🏴

pub package

Convert 🌍 Locale (language code, script code and country code) to the corresponding 🏳️ Emoji Flag 🏴.
Inspired from the JS locale-emoji package.

Features

  • πŸš€ Written in pure dart
  • 🎈 NO dependencies
  • πŸ“± Flutter package for Locale extension (locale_emoji_flutter)
  • ✨ Safe to use as much as it could be

Usage

import 'package:locale_emoji/locale_emoji.dart' as le;

//...

final flagDe = le.getFlagEmoji(countryCode: 'DE'); // πŸ‡©πŸ‡ͺ
final flagDe = le.getFlagEmoji(languageCode: 'de'); // πŸ‡©πŸ‡ͺ

final flagSk = le.getFlagEmoji(languageCode: 'sk'); // πŸ‡ΈπŸ‡°
final flagSk = le.getFlagEmoji(countryCode: 'SK'); // πŸ‡ΈπŸ‡°
final flagSk = le.getFlagEmoji(languageCode: 'sk', scriptCode: 'Latin', countryCode: 'SK'); // πŸ‡ΈπŸ‡°

Flutter

For flutter, use locale_emoji_flutter package instead.

import 'package:locale_emoji_flutter/locale_emoji_flutter.dart';

//...

final Locale localeDe = Locale('de');
final Locale localeSk = Locale.fromSubtags(
  languageCode: 'sk',
  scriptCode: 'Latin',
  countryCode: 'SK',
);

final flagDe = localeDe.flagEmoji; // πŸ‡©πŸ‡ͺ
final flagSk = localeSk.flagEmoji; // πŸ‡ΈπŸ‡°

Additional information

Defaults might be updated in the origin: cldr-core. In case of any updates in cldr-core, please, run the following command in the root of the repository and submit a PR.

dart tools/update_defaults.dart

Support

Buy Me A Coffee

About

Convert 🌍 Locale (languageCode, scriptCode and countryCode) to the corresponding 🏳️ Emoji Flag 🏴.

Topics

Resources

License

Stars

Watchers

Forks

Languages