Pakete, Repositories und App-Kategorien suchen

Cover von country_codes
Paketdetailsv3.3.0

country_codes

Ländercodes ist ein Hilfspaket, das Länderdetails unter Berücksichtigung einer bestimmten Lokalisierung bereitstellt, wie etwa Vorwahlnummern, ISO-3166-Codes (Alpha-2, Alpha-3) und Ländernamen.

AndroidiOSmacOS
30-Tage-Downloads
33.900
Likes
134
Pub-Punkte
150

Paket installieren

flutter pub add country_codes

Paketübersicht

Aus öffentlichen Paketdaten erstellte Orientierung.

Country Codes ist ein Flutter/Dart-Paket, das umfassende Länderinformationen basierend auf Lokalisierung bereitstellt, einschließlich Vorwahlnummern, ISO-3166-Alpha-2- und Alpha-3-Codes sowie lokalisierten Ländernamen. Es vereinfacht die Handhabung internationaler Daten durch konsistenten Zugriff auf Länderdetails in verschiedenen Regionen. Das Paket ist leichtgewichtig und für den Einsatz in Formularen, Länderauswahlkomponenten und Lokalisierungsworkflows konzipiert. Es unterstützt Android, iOS und macOS-Plattformen und ist daher ideal für plattformübergreifende Anwendungen, die präzise Ländermetadaten erfordern.

Anwendungsfälle

  • Internationale Telefonnummer-Eingabe
  • Landauswahl in Formularen
  • Lokalisierung von Ländernamen
  • Datenüberprüfung mit ISO-Codes
  • Landauswahlfelder erstellen

Hauptmerkmale

  • Unterstützt mehrere Länderkennungen
  • Lokalisierte Ländernamen
  • Dialcode-Suche
  • ISO 3166 Alpha-2- und Alpha-3-Codes
  • Plattformübergreifende Kompatibilität

Geeignet für

  • Apps, die Landesdaten benötigen
  • Formulareingaben mit Landauswahl
  • Internationalisierungsfunktionen
  • Mobile Apps mit globalen Nutzern
  • Entwickler, die Länderauswahl erstellen

Hinweise

  • Benötigt manuelle Behandlung von Lokalisierungsrückfällen
  • Keine integrierten Benutzeroberflächenkomponenten
  • Beschränkt auf statische Länderdaten
  • Enthält keine Zeitzone- oder Währungsinformationen
  • Abhängig von der korrekten Lokalisierungskonfiguration

Original-README

Originaler README-Schnappschuss aus dem verknüpften Quell-Repository. Aktuelle Inhalte finden Sie im Repository.

Country Codes

Country Codes Build Status Buy me a coffee

Country codes package provides an easy to way to access country codes based on a provided Locale.

Usage

There are two main ways to use this package.

1. Default by using device region

This will allow you to fetch the region of the underlying platform and display the data accordingly. Very handy if you use along with the DialCodeFormatter to provide integration with dial codes formatter, on phone TextFormFields in a Form, for example.

Assuming an en-US region based revice.

await CountryCodes.init(); // Optionally, you may provide a `Locale` to get countrie's localizadName

final Locale deviceLocale = CountryCodes.getDeviceLocale();
print(deviceLocale.languageCode); // Displays en
print(deviceLocale.countryCode); // Displays US

final CountryDetails details = CountryCodes.detailsForLocale();
print(details.alpha2Code); // Displays alpha2Code, for example US.
print(details.dialCode); // Displays the dial code, for example +1.
print(details.name); // Displays the extended name, for example United States.
print(details.localizedName); // Displays the extended name based on device's language (or other, if provided on init)
2. Use a custom Locale

This will use the provided Locale, which may not be related to the device's region but instead to the app supported languages.

For example, if your device is on US region but the app only supports PT, you'll get the following:

final CountryDetails details = CountryCodes.detailsForLocale(Localization.localeOf(context));

print(details.alpha2Code); // Displays alpha2Code, displays PT.
print(details.dialCode); // Displays the dial code for PT, +351.
print(details.name); // Displays the extended name, Portugal.

Formatters

DialCodeFormatter

Currently there's only available TextInputFormatter which allows you to dynamically set the dial code dynamically on a TextFormField.

TextFormField(
  keyboardType: TextInputType.phone,
  inputFormatters: [DialCodeFormatter()],
);

Example app

Example

Getting Started

This project is a starting point for a Dart package, a library module containing code that can be shared easily across multiple Flutter or Dart projects.

For help getting started with Flutter, view our online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.

Kategorien

Quell-Repository

Projekte, die dieses Paket verwenden