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

country_calling_code_picker 표지
패키지 상세v2.0.1

country_calling_code_picker

국가 코드와 통화 코드를 얻기 위한 유연한 국가 선택기입니다.

AndroidiOS
30일 다운로드
229
좋아요
45
Pub 점수
150

패키지 설치

flutter pub add country_calling_code_picker

패키지 개요

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

사용자가 국가를 선택하고 해당 국가 코드 및 통화 코드를 가져올 수 있도록 해주는 유연하고 사용자 정의 가능한 Flutter 국가 선택 위젯입니다. 국제 전화번호 입력이 필요한 양식에 원활하게 통합되도록 설계되었으며, 안드로이드와 iOS 플랫폼을 모두 지원합니다. 검색 기능과 국기 표시를 갖춘 직관적인 인터페이스를 제공하여 국가 선택 시 사용자 경험을 향상시킵니다. 가볍고 구현이 쉬워 국제 전화 번호 정보가 정확히 필요할 때 앱에 이상적입니다.

사용 사례

  • 국제 전화번호 입력
  • 사용자 프로필 설정 및 국가 선택
  • 다중 지역 앱 로컬라이제이션
  • 국가 코드 지원이 있는 연락 양식
  • 전화 인증이 필요한 인증 흐름

주요 기능

  • 검색 가능한 국가 목록
  • 국가 국기의 표시
  • 통화 코드 자동 검색
  • 사용자 정의 가능한 UI 테마
  • 국가 코드 및 통화 코드 출력 모두 지원

적합한 대상

  • 국제 전화 입력이 필요한 모바일 앱
  • 사용자 온보딩 흐름
  • 글로벌 전자상거래 플랫폼
  • 메시징 또는 통화 앱
  • 국제 연락처 정보를 포함한 폼

고려 사항

  • 국가 코드 저장을 수동으로 처리해야 합니다
  • 기본 스타일링을 초과한 제한된 사용자 정의
  • 전화번호에 대한 내장 검증 없음
  • 국가 목록에 대한 외부 데이터 소스에 의존합니다
  • 시간대 또는 언어 일치를 위해 추가적인 로직이 필요할 수 있습니다

원본 README

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

Country Calling Code Picker

pub package

A searchable country picker for Flutter, ready to use in a dialog, a bottom sheet or full screen. Gives you the country name, its ISO code, its international calling code and a bundled flag image for 250 countries and territories.

Pure Dart — no platform channels, no native build setup. It runs on Android, iOS, web, macOS, Windows and Linux.

Install

dependencies:
  country_calling_code_picker: ^3.0.0
import 'package:country_calling_code_picker/picker.dart';

Usage

Pre-select the country the device is set to
class _MyPageState extends State<MyPage> {
  Country? _selectedCountry;
  bool _didInit = false;

  @override
  void didChangeDependencies() {
    super.didChangeDependencies();
    if (!_didInit) {
      _didInit = true;
      _initCountry();
    }
  }

  Future<void> _initCountry() async {
    final country = await getDefaultCountry(context);
    if (!mounted) return;
    setState(() => _selectedCountry = country);
  }
}

getDefaultCountry resolves the device region from the platform locale. Pass fallbackCountryCode to choose what happens when the platform reports a region that is not in the list:

final country = await getDefaultCountry(context, fallbackCountryCode: 'US');
Bottom sheet
final country = await showCountryPickerSheet(context);
if (country != null) {
  setState(() => _selectedCountry = country);
}
Dialog
final country = await showCountryPickerDialog(context);
Full screen
class PickerPage extends StatelessWidget {
  const PickerPage({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text('Select country')),
      body: CountryPickerWidget(
        onSelected: (country) => Navigator.pop(context, country),
      ),
    );
  }
}
Just the data
// Every country, for your own custom picker.
final List<Country> countries = await getCountries(context);

// Or without a BuildContext, e.g. from a repository or a unit test.
final List<Country> countries = await getCountriesFromBundle();

// A single country by ISO code (case insensitive, null when unknown).
final Country? india = await getCountryByCountryCode(context, 'IN');

// The device region, e.g. 'IN'. Null when the platform reports none.
final String? code = getDeviceCountryCode(context);
Showing a flag

Flag images ship inside this package, so they need the package name:

Image.asset(country.flag, package: countryCodePackageName, width: 32);

Or skip the images entirely and use the emoji flag:

Text(country.flagEmoji); // 🇮🇳

CountryPickerWidget options

Parameter Default Description
onSelected null Called with the tapped Country.
itemTextStyle TextStyle(fontSize: 16) Text style of a list item.
searchInputStyle TextStyle(fontSize: 16) Text style of the search box.
searchInputDecoration null Replaces the search box decoration entirely.
searchHintText 'Search country name, code' Hint of the search box.
flagIconSize 32 Width of the flag image.
showSeparator false Draw a Divider between items.
focusSearchBox false Open the keyboard as soon as the picker shows.
showDeviceCountryFirst true Move the device's country to the top of the list.

Search matches the country name (accent insensitive, so aland finds Åland), the ISO code, and the calling code with or without its leading +.

Upgrading from 2.x

Version 3.0.0 requires Dart 3 / Flutter 3.24 or newer.

  • The flutter_sim_country_code dependency is gone. getDefaultCountry now reads the device region from the platform locale instead of the SIM card, which is why the package no longer needs any native code and works on web and desktop. On a device whose region setting and SIM disagree, the resolved country can differ from 2.x.
  • getCountryByCountryCode now really returns null for an unknown code. It used to throw a StateError. Its match is also case insensitive now.
  • The country matching the device is still moved to the top of the picker, but countries that merely share its calling code are no longer removed from the list — picking the US no longer made Canada disappear.
  • getDefaultCountry takes an optional fallbackCountryCode.
  • CountryPickerWidget.focusSearchBox is now actually forwarded by showCountryPickerSheet and showCountryPickerDialog.

License

MIT — see LICENSE.

카테고리

의존성

의존성 목록 1 개

소스 저장소

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

아직 데이터가 없습니다.