搜索插件、代码仓与 APP 分类

插件详情v3.0.0

flutter_country_selector

如何使用国家选择器来选择国家

AndroidiOSWebmacOSWindowsLinux
近 30 天下载
5.6万
喜欢数
12
Pub 分数
160

安装插件

flutter pub add flutter_country_selector

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

一个 Flutter 包,提供用于选择国家的国家选择器小部件,非常适合需要输入国家信息的表单。它支持多种平台,包括 Android、iOS、Web、macOS、Windows 和 Linux。选择器显示国家名称和国旗,使用户能够通过简洁直观的界面轻松选择国家。该包轻量且可无缝集成到现有的 Flutter 应用中。该包是开源的,并在 GitHub 上维护,允许社区贡献并保持透明度。

适合场景

  • 用户注册并选择国家
  • 国际表单输入
  • 带国家代码的电话号码输入
  • 旅行或邮寄地址表单
  • 多语言应用本地化

主要特点

  • 显示国家旗帜和名称
  • 支持跨平台部署
  • 与 Flutter 表单轻松集成
  • 可自定义外观
  • 开源且持续维护

适合对象

  • 开发国际应用的开发者
  • 需要特定国家数据的应用
  • 表单密集型应用
  • 跨平台移动和Web项目

使用建议

  • 可能需要额外的样式设置以支持自定义主题
  • 仅限国家选择(不支持地区或城市)
  • 依赖外部标志资源
  • 未针对非常大的国家列表进行优化

原始 README

以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。

Flutter Country Selector

Country selector of the phone_form_field package exported in its own package.

Features

  • localization: lots of supported languages
  • semantics applied

Demo

Demo available here: https://cedvdb.github.io/flutter_country_selector/

Usage

Use CountrySelector.page if you need to show the selector inside a widget that is full screen. If you need to show the selector inside a modal of some sort, use CountrySelector.sheet instead.

Navigator.of(context).push(
  MaterialPageRoute(
    builder: (ctx) => CountrySelector.page(
      onCountrySelected: (country) => Navigator.of(context).pop(country),
    ),
  ),
)

Localization

Dynamic localization

Use CountrySelectorLocalization.of(context)?.countryName(isoCode) when you need to dynamically localize the name of a country.

Supported languages
  • ar
  • de
  • el
  • en
  • es
  • fa
  • fr
  • he
  • hi
  • hu
  • it
  • ko
  • ku
  • nb
  • nl
  • pl
  • pt
  • ru
  • sv
  • tr
  • uk
  • ur
  • uz
  • vi
  • zh
Setup

Example setup:


const MaterialApp(
  locale: Locale('en'),
  supportedLocales: [
    Locale('en'),
  ],
  localizationsDelegates: [
    GlobalMaterialLocalizations.delegate,
    CountrySelectorLocalization.delegate,
  ],
  // ...
)

Overwriting or adding custom flags

Some users have expressed their need to change some flags due to political reasons, or stylistic reasons. You might also wish to add your own flags. To do so refer to this issue: https://github.com/cedvdb/phone_form_field/issues/222

所属分类

依赖

依赖清单 1 项

源码仓库

使用此插件的项目