搜尋套件、儲存庫與 APP 分類

套件詳情v0.1.6

country_state_city

一個 Flutter 套件,根據給定國家顯示國家、州和城市清單

AndroidiOSWebmacOSWindowsLinux
近 30 天下載
1.5萬
喜歡數
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

所屬分類

原始碼儲存庫

使用此套件的專案

暫無相關資料。