Lande
Lande
Pakken indeholder 248+ lande med fuld ISO 3166-1-metadata.
Landeegenskaber
Hvert land har foelgende felter:
| Felt | Beskrivelse |
|---|---|
alpha2Code | ISO 3166-1 alpha-2-kode (f.eks. "US") |
alpha3Code | ISO 3166-1 alpha-3-kode (f.eks. "USA") |
numericCode | ISO 3166-1 numerisk kode (f.eks. 840) |
nativeName | Oprindeligt landenavn |
capital | Hovedstad |
mainLanguage | Primaer sprogkode |
languages | Liste over talte sprogkoder |
tld | Topdomaene (f.eks. ".us") |
callingCode | Internationalt opkaldsnummer (f.eks. 1) |
continent | Kontinent-identifikator |
currency | Primaer valutakode |
Opslag efter kode
Alpha-2-kode
final country = Country.fromAlpha2Code('US');
print(country?.nativeName); // United States
print(country?.capital); // Washington, D.C.Alpha-3-kode
final country = Country.fromAlpha3Code('USA');
print(country?.alpha2Code); // USNumerisk kode (kun Dart)
final country = Country.fromNumericCode(840);
print(country?.nativeName); // United States
Liste over alle lande
final allCountries = Country.values;
print(allCountries.length); // 253Filtrer efter kontinent
final european = Continent.europe.countries;
for (final c in european) {
print(c.nativeName);
}SVG-flag
Hvert land har et inline SVG-flag tilgaengeligt som en streng.
// Tilg via countryFlags-map'et
final svg = countryFlags['US'];
// Eller via Country-egenskaben
final country = Country.fromAlpha2Code('US');
final flagSvg = country?.flagSvg;
// Renderer som en Flutter-widget
country?.flag(
shape: FlagShape.rectangle,
width: 32,
height: 24,
);Emoji-flag
final country = Country.fromAlpha2Code('US');
print(country?.emojiFlag);Landemetadata
final country = Country.fromAlpha2Code('JP');
print(country?.callingCode); // 81
print(country?.tld); // .jp
print(country?.currency.code); // JPY
print(country?.continent.code); // AS
print(country?.mainLanguage.code); // ja