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

插件详情v0.1.6

country_state_city

一个 Flutter 包,可根据给定国家显示国家、省份和城市列表

AndroidiOSWebmacOSWindowsLinux
近 30 天下载
1.6万
喜欢数
41
Pub 分数
160

安装插件

flutter pub add country_state_city

插件介绍

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

一个 Flutter 包,提供了一种简单的方式来显示基于所选国家的国家、州和城市列表。它支持动态填充州和城市下拉框,非常适合需要基于位置的数据输入表单。该包支持多种平台,包括 Android、iOS、Web、macOS、Windows 和 Linux,确保跨平台一致性。它轻量且易于集成,设置要求极少。

适合场景

  • 表单输入需要位置选择
  • 动态状态和城市下拉菜单
  • 用户注册包含位置字段
  • 电子商务物流地址收集
  • 多语言位置支持

主要特点

  • 根据国家自动填充状态和城市
  • 支持所有主要平台
  • 轻量且易于集成
  • 全局位置的预加载数据
  • 简单的 API,配置最少

适合对象

  • 开发国际应用的开发者
  • 需要动态位置选择的应用程序
  • 包含国家-州-城市层级的表单
  • 需要位置数据的跨平台应用程序

使用建议

  • 初始数据加载需要互联网连接(如果未打包)
  • UI 组件的自定义功能有限
  • 数据集大小可能影响初始加载时间
  • 无内置本地化支持
  • 依赖外部数据源以确保准确性

原始 README

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

country_state_city

version version

A flutter package to display list of world wide Countries, States and Cities. It also allows to get a list of States and Cities depends on given country (by ISO CODE).

How to Use

To use this Package, add country_state_city as a dependency in your pubspec.yaml.

// import country_state_city package
import 'package:country_state_city/country_state_city.dart';
// Get all countries
final countries = await getAllCountries();

// Get all states that belongs to a country by country ISO CODE
final states = await getStatesOfCountry('AF'); // Afghanistan

APIs

Function Description
Future<List<Country>> getAllCountries() Get world wide countries list.
Future<Country?> getCountryFromCode(String countryCode) Get country from its ISO CODE
Future<List<State>> getAllStates() Get world wide states list.
Future<List<State>> getStatesOfCountry(String countryCode) Get the list of states that belongs to a country by the country ISO CODE
Future<State?> getStateByCode(String countryCode, String stateCode,) Get a state from its code and its belonging country code
Future<List<City>> getAllCities() Get world wide cities list.
Future<List<City>> getStateCities(String countryCode, String stateCode) Get the list of states that belongs to a state by the state ISO CODE and the country ISO CODE
Future<List<City>> getCountryCities(String countryCode) Get the list of cities that belongs to a country by the country ISO CODE

Classes

Class Description
Country Handle country data such as: (name, isoCode, phoneCode, flag, currency, latitude, longitude, timezones)
State Handle state data such as: (name, countryCode, isoCode, latitude, longitude)
City Handle city data such as: (name, countryCode, stateCode, latitude, longitude)
Timezone Handle timezone data such as: (name, gmtOffset, gmtOffsetName, abbreviation, tzName)
Special Thanks to

所属分类

源码仓库

使用此插件的项目

暂无相关数据。