DefaultCountryDataSource

The library's bundled country dataset: every ISO 3166-1 country and territory that has an international dial code, with ISO alpha-2, alpha-3, region and search aliases.

This is the single source of truth for country metadata. The legacy com.ezzy.ccp.data.countryList is derived from it rather than maintained separately.

The rows are held as one delimited string and parsed exactly once, on first access. That keeps the constant pool small (236 rows × 5 fields as separate object literals is a measurable APK and class-init cost) and guarantees the dataset is never rebuilt during composition.

Names are English-by-default. localizedNames resolves each country's name through the platform's own region names (ICU on Android, NSLocale on iOS) when it has a translation, so a French device shows "Allemagne" for DE without the library shipping its own translation table.

Properties

Link copied to clipboard

Fast lookup by ISO alpha-2 code (uppercase).

Link copied to clipboard

English-named countries, sorted by name. Stable across calls and across locales.

Functions

Link copied to clipboard

The country a phone field starts on when the caller names none, with its name in locale.

Link copied to clipboard

Every country whose dial code matches dialCode, with or without a leading +.

Link copied to clipboard
fun findByIso2(code: String?): Country?

Looks up a country by ISO alpha-2 code, case-insensitively.

fun findByIso2(code: String?, locale: Locale): Country?

Looks up a country by ISO alpha-2 code with its name in locale.

Link copied to clipboard
Link copied to clipboard
fun flagEmoji(iso2Code: String): String?

Builds the regional-indicator emoji flag for an ISO alpha-2 code.

Link copied to clipboard
open suspend override fun load(): List<Country>

The list the picker shows: country names in the device's language, sorted for that language.

Link copied to clipboard

Returns countries with Country.displayName replaced by the platform's translation for locale where one exists, re-sorted with a locale-aware collator.

Link copied to clipboard
Link copied to clipboard

Uppercases and maps well-known non-ISO codes (UK → GB) to their canonical form.

Link copied to clipboard

The conventional "main" country for a shared dial code — +1 → United States, +44 → United Kingdom, +7 → Russia — falling back to the first match by name.