🌍 country_meta

Pub Version

A Dart-only package providing metadata for countries with ISO codes, localized names, currencies, phone codes, and flag image utilities (SVG, WebP, JPEG, Emoji).


πŸ“¦ Features

  • βœ… ISO Alpha-2, Alpha-3, and Numeric codes
  • πŸ“ž Phone codes
  • πŸ’± Currencies and symbols
  • 🌐 Localized country names: English, Russian, Arabic
  • πŸ”Ž Country lookup by code or locale
  • 🏁 Flag support: Emoji, SVG / WebP / JPEG (FlagCDN)
  • πŸ§ͺ Unit tests for model serialization, equality, and indexing

πŸ‡ΊπŸ‡³ Flag icons provided by flagpedia.net

πŸš€ Usage

πŸ” Country Lookup

final country = CountryRepository.byAlpha2('US');
print(country?.currency); // USD
print(country?.phoneCode); // 1

🌐 Localized Name

final name = country?.localizedName('ru_RU');
print(name); // Π‘ΠΎΠ΅Π΄ΠΈΠ½Π΅Π½Π½Ρ‹Π΅ Π¨Ρ‚Π°Ρ‚Ρ‹

🏁 Flag URL

// Default SVG
final svg = country?.flagUrl();

// JPEG with height
final jpeg = country?.flagUrl(
  format: FlagImageFormat.jpeg,
  height: FlagHeight.h160,
);

// WebP with width
final webp = country?.flagUrl(
  format: FlagImageFormat.webp,
  width: FlagWidth.w320,
);

πŸ˜€ Emoji Flag

final emoji = country?.flagEmoji();
print(emoji); // πŸ‡ΊπŸ‡Έ

⚑️ Direct Flag Access

You don’t need to resolve a full CountryMeta to show a flag. Both emoji and image URLs can be generated directly from ISO alpha-2 codes.

// Emoji flags
print(FlagEmojiBuilder.build('US')); // πŸ‡ΊπŸ‡Έ
print(FlagEmojiBuilder.build('DE')); // πŸ‡©πŸ‡ͺ

// Flag URLs
print(FlagUrlBuilder.svg('US'));                // https://flagcdn.com/us.svg
print(FlagUrlBuilder.webp('US', width: FlagWidth.w40));
print(FlagUrlBuilder.jpeg('JP', height: FlagHeight.h80));

πŸ§ͺ Testing

Run all tests:

dart test

Includes tests for:

  • βœ… CountryMeta model parsing, serialization, equality
  • πŸ“¦ Country repository lookup
  • 🌐 Localized name fallback logic
  • 🏁 Flag URL generation and format fallback

πŸ“„ License

MIT

Libraries

country_meta