🌍 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).


πŸ“¦ 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 URL builder with SVG / WebP / JPEG support
  • πŸ§ͺ Unit tests for model serialization, equality, and indexing

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


πŸ“ Project Structure

lib/
β”œβ”€β”€ country_meta.dart
└── src/
    β”œβ”€β”€ model/
    β”‚   └── country_meta.dart
    β”œβ”€β”€ data/
    β”‚   └── country_repository.dart
    β”œβ”€β”€ res/
    β”‚   β”œβ”€β”€ data/
    β”‚   β”‚   └── countries_raw_data.dart
    β”‚   └── names/
    β”‚       β”œβ”€β”€ country_names_en.dart
    β”‚       β”œβ”€β”€ country_names_ru.dart
    β”‚       β”œβ”€β”€ country_names_ar.dart
    β”œβ”€β”€ localization/
    β”‚   β”œβ”€β”€ localized_name.dart
    β”‚   └── country_name.dart
    └── flags/
        β”œβ”€β”€ flag_format.dart
        β”œβ”€β”€ flag_width.dart
        β”œβ”€β”€ flag_height.dart
        β”œβ”€β”€ flag_url_builder.dart
        └── country_flag.dart

πŸš€ 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,
);

πŸ§ͺ 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