패키지, 저장소 및 앱 카테고리 검색

country_codes 표지
패키지 상세v3.3.0

country_codes

국가 코드는 특정 로컬라이제이션에 따라 국가 정보를 제공하는 도우미 패키지입니다. 예: 전화 번호 접두사, ISO 3166 코드(알파-2, 알파-3), 국가 이름 등.

AndroidiOSmacOS
30일 다운로드
3.4만
좋아요
134
Pub 점수
150

패키지 설치

flutter pub add country_codes

패키지 개요

공개 정보를 바탕으로 생성한 선택 가이드입니다.

국가 코드는 로컬라이제이션 기반의 포괄적인 국가 정보를 제공하는 Flutter/Dart 패키지입니다. 전화 코드, ISO 3166 알파-2 및 알파-3 코드, 그리고 현지화된 국가 이름을 포함합니다. 다양한 지역에서 일관된 국가 정보에 접근할 수 있도록 하여 국제 데이터 처리를 간소화합니다. 이 패키지는 가볍고 폼, 국가 선택기, 로컬라이제이션 워크플로우에 적합하도록 설계되었습니다. Android, iOS, macOS 플랫폼을 지원하여 정확한 국가 메타데이터가 필요한 크로스플랫폼 애플리케이션에 이상적입니다.

사용 사례

  • 국제 전화번호 입력
  • 양식 내 국가 선택
  • 국가 이름의 현지화
  • ISO 코드를 사용한 데이터 검증
  • 국가 선택기 위젯 만들기

주요 기능

  • 여러 국가 식별자 지원
  • 현지화된 국가 이름
  • 다이얼 코드 검색
  • ISO 3166 알파-2 및 알파-3 코드
  • 크로스 플랫폼 호환성

적합한 대상

  • 국가 데이터가 필요한 앱
  • 국가 선택이 있는 폼 입력
  • 국제화 기능
  • 글로벌 사용자가 있는 모바일 앱
  • 국가 선택기 개발하는 개발자

고려 사항

  • 로케일 백업을 수동으로 처리해야 합니다
  • 내장된 UI 컴포넌트 없음
  • 정적 국가 데이터에 한정
  • 시간대 또는 화폐 정보를 포함하지 않습니다
  • 정확한 로케일 구성에 의존합니다

원본 README

연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.

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.

카테고리

소스 저장소

이 패키지를 사용하는 프로젝트