import 'dart:ui'; extension LocaleParsing on String { Locale parseLocale() { assert(contains('_') == true); var languageCode = split('_').first; var countryCode = split('_').last; return Locale.fromSubtags( languageCode: languageCode, countryCode: countryCode); } String toLangIcon() { assert(length == 2); switch (toLowerCase()) { case 'us': case 'en': return '๐Ÿ‡บ๐Ÿ‡ธ'; case 'ru': return '๐Ÿ‡ท๐Ÿ‡บ'; case 'am': case 'hy': return '๐Ÿ‡ฆ๐Ÿ‡ฒ'; default: return '๐Ÿ‡บ๐Ÿ‡ธ'; } } String toLangName() { assert(length == 2); switch (toLowerCase()) { case 'us': case 'en': return toLangIcon() + ' English'; case 'ru': return toLangIcon() + ' ะ ัƒััะบะธะน'; case 'am': case 'hy': return toLangIcon() + ' ี€ีกีตีฅึ€ีฅีถ'; default: return toLangIcon() + ' English'; } } String toLangCode() { assert(contains('_') == true); return split('_').first; } }