국가 코드는 로컬라이제이션 기반의 포괄적인 국가 정보를 제공하는 Flutter/Dart 패키지입니다. 전화 코드, ISO 3166 알파-2 및 알파-3 코드, 그리고 현지화된 국가 이름을 포함합니다. 다양한 지역에서 일관된 국가 정보에 접근할 수 있도록 하여 국제 데이터 처리를 간소화합니다. 이 패키지는 가볍고 폼, 국가 선택기, 로컬라이제이션 워크플로우에 적합하도록 설계되었습니다. Android, iOS, macOS 플랫폼을 지원하여 정확한 국가 메타데이터가 필요한 크로스플랫폼 애플리케이션에 이상적입니다.
사용 사례
국제 전화번호 입력
양식 내 국가 선택
국가 이름의 현지화
ISO 코드를 사용한 데이터 검증
국가 선택기 위젯 만들기
주요 기능
여러 국가 식별자 지원
현지화된 국가 이름
다이얼 코드 검색
ISO 3166 알파-2 및 알파-3 코드
크로스 플랫폼 호환성
적합한 대상
국가 데이터가 필요한 앱
국가 선택이 있는 폼 입력
국제화 기능
글로벌 사용자가 있는 모바일 앱
국가 선택기 개발하는 개발자
고려 사항
로케일 백업을 수동으로 처리해야 합니다
내장된 UI 컴포넌트 없음
정적 국가 데이터에 한정
시간대 또는 화폐 정보를 포함하지 않습니다
정확한 로케일 구성에 의존합니다
원본 README
연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.
Country Codes
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.
awaitCountryCodes.init(); // Optionally, you may provide a `Locale` to get countrie's localizadNamefinalLocale deviceLocale = CountryCodes.getDeviceLocale();
print(deviceLocale.languageCode); // Displays enprint(deviceLocale.countryCode); // Displays USfinalCountryDetails 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:
finalCountryDetails 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.
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.