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

csc_picker 封面
套件詳情v0.2.7

csc_picker

一個 Flutter 套件,用於根據所選內容顯示國家、州和城市清單,您還可以在全球範圍內搜尋國家、州和城市。

近 30 天下載
1860
喜歡數
223
Pub 分數
70

安裝套件

flutter pub add csc_picker

套件介紹

根據套件公開資料產生的選型評估,僅供參考。

csc_picker 是一個 Flutter 套件,允許使用者以階層式下拉結構選擇國家、州與城市。它支援在全球範圍內搜尋所有國家、州與城市,非常適合需要位置輸入的表單。此套件輕量且易於整合,提供根據使用者選擇的國家、州與城市選擇之乾淨介面。在需要國際地址輸入或區域特定資料收集的應用中特別實用。

適用情境

  • 國際地址格式
  • 使用者檔案位置設定
  • 電子商務運輸詳情
  • 旅行預訂系統
  • 多區域應用本地化

主要特色

  • 層級國家-省-城市選擇
  • 全域搜尋功能
  • 輕量且易於整合
  • 支援選擇項目之間的動態依賴關係
  • 乾淨且可自定義的使用者介面

適合對象

  • 需要國際位置輸入的應用程式
  • 帶有多層次位置欄位的表單
  • 尋求簡單國家選擇器的開發者
  • 具有全球用戶基礎的項目
  • 具有本地化需求的移動應用

使用建議

  • 不包含離線資料快取
  • 下拉選單外觀的自訂選項有限
  • 需要互聯網才能使用完整的搜尋功能
  • 不支援自訂區域或非標準層次結構
  • 初始載入在大資料集上可能較慢

原始 README

以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。

csc_picker

version version

A flutter package to display a country, states, and cities. In addition it gives the possibility to select a list of countries, States and Cities depends on Selected, also you can search country, state, and city all around the world.

Horizontal Layout Vertical Layout

How to Use

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

      	CSCPicker(
              onCountryChanged: (value) {
      			setState(() {
      					countryValue = value;
      				});
                  },
                  onStateChanged:(value) {
                      setState(() {
      					stateValue = value;
      				});
                  },
                  onCityChanged:(value) {
                  setState(() {
                      cityValue = value;
      			});
      		},
          ),

you will get feedback in onChanged functions

Parameters
ParametersTypeDescription
flagStateCountryFlagEnable (get flag with country name) / Disable (Disable flag) / ShowInDropdownOnly (display flag in dropdown only)
layoutLayoutToggle dropdown layout (Horizontal / Vertical)
showStatesBoolean Enable disable States dropdown (true / false)
showCitiesBoolean Enable disable Cities dropdown (true / false)
dropdownDecorationBoxDecorationDropdown box decoration to style your dropdown selector [OPTIONAL PARAMETER] (USE with disabledDropdownDecoration)
disabledDropdownDecorationBoxDecorationDisabled Dropdown box decoration to style your dropdown selector [OPTIONAL PARAMETER] (USE with disabled dropdownDecoration)
selectedItemStyleTextStyleTo change selected item style
dropdownHeadingStyleTextStyleTo change DropdownDialog Heading style
dropdownItemStyleTextStyleTo change DropdownDialog Item style
dropdownDialogRadiusdoubleTo change DropdownDialogBox radius
searchBarRadiusdoubleTo change search bar radius
defaultCountryCscCountryTo select default country
disableCountryBooleanDisable country dropdown (Note: use it with default country)
countryFilterList of CscCountryShow only countries in dropdown that you want
countrySearchPlaceholderStringPlaceholder for country search field
stateSearchPlaceholderStringPlaceholder for state search field
citySearchPlaceholderStringPlaceholder for city search field
countryDropdownLabelStringLabel/Title for country dropdown
countryDropdownLabelStringLabel/Title for state dropdown
countryDropdownLabelStringLabel/Title for city dropdown
Example
import 'package:csc_picker/csc_picker.dart';
import 'package:flutter/material.dart';

/// This is a implementation of the Country State City Picker.
void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'CSC Picker',
      theme: ThemeData(
        primarySwatch: Colors.blue,
        visualDensity: VisualDensity.adaptivePlatformDensity,
      ),
      home: MyHomePage(title: 'CSC Picker'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);

  final String title;

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  /// Variables to store country state city data in onChanged method.
  String countryValue = "";
  String stateValue = "";
  String cityValue = "";
  String address = "";

  @override
  Widget build(BuildContext context) {

    GlobalKey<CSCPickerState> _cscPickerKey = GlobalKey();

    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Center(
        child: Container(
            padding: EdgeInsets.symmetric(horizontal: 20),
            height: 600,
            child: Column(
              children: [
                ///Adding CSC Picker Widget in app
                CSCPicker(
                  ///Enable disable state dropdown [OPTIONAL PARAMETER]
                  showStates: true,

                  /// Enable disable city drop down [OPTIONAL PARAMETER]
                  showCities: true,

                  ///Enable (get flag with country name) / Disable (Disable flag) / ShowInDropdownOnly (display flag in dropdown only) [OPTIONAL PARAMETER]
                  flagState: CountryFlag.DISABLE,

                  ///Dropdown box decoration to style your dropdown selector [OPTIONAL PARAMETER] (USE with disabledDropdownDecoration)
                  dropdownDecoration: BoxDecoration(
                      borderRadius: BorderRadius.all(Radius.circular(10)),
                      color: Colors.white,
                      border:
                      Border.all(color: Colors.grey.shade300, width: 1)),

                  ///Disabled Dropdown box decoration to style your dropdown selector [OPTIONAL PARAMETER]  (USE with disabled dropdownDecoration)
                  disabledDropdownDecoration: BoxDecoration(
                      borderRadius: BorderRadius.all(Radius.circular(10)),
                      color: Colors.grey.shade300,
                      border:
                      Border.all(color: Colors.grey.shade300, width: 1)),

                  ///placeholders for dropdown search field
                  countrySearchPlaceholder: "Country",
                  stateSearchPlaceholder: "State",
                  citySearchPlaceholder: "City",

                  ///labels for dropdown
                  countryDropdownLabel: "*Country",
                  stateDropdownLabel: "*State",
                  cityDropdownLabel: "*City",

                  ///Default Country
                  //defaultCountry: CscCountry.India,

                  ///Disable country dropdown (Note: use it with default country)
                  //disableCountry: true,

                  ///Country Filter [OPTIONAL PARAMETER]
                  countryFilter: [CscCountry.India,CscCountry.United_States,CscCountry.Canada],

                  ///selected item style [OPTIONAL PARAMETER]
                  selectedItemStyle: TextStyle(
                    color: Colors.black,
                    fontSize: 14,
                  ),

                  ///DropdownDialog Heading style [OPTIONAL PARAMETER]
                  dropdownHeadingStyle: TextStyle(
                      color: Colors.black,
                      fontSize: 17,
                      fontWeight: FontWeight.bold),

                  ///DropdownDialog Item style [OPTIONAL PARAMETER]
                  dropdownItemStyle: TextStyle(
                    color: Colors.black,
                    fontSize: 14,
                  ),

                  ///Dialog box radius [OPTIONAL PARAMETER]
                  dropdownDialogRadius: 10.0,

                  ///Search bar radius [OPTIONAL PARAMETER]
                  searchBarRadius: 10.0,

                  ///triggers once country selected in dropdown
                  onCountryChanged: (value) {
                    setState(() {
                      ///store value in country variable
                      countryValue = value;
                    });
                  },

                  ///triggers once state selected in dropdown
                  onStateChanged: (value) {
                    setState(() {
                      ///store value in state variable
                      stateValue = value;
                    });
                  },

                  ///triggers once city selected in dropdown
                  onCityChanged: (value) {
                    setState(() {
                      ///store value in city variable
                      cityValue = value;
                    });
                  },
                ),

                ///print newly selected country state and city in Text Widget
                TextButton(
                    onPressed: () {
                      setState(() {
                        address = "$cityValue, $stateValue, $countryValue";
                      });
                    },
                    child: Text("Print Data")),
                Text(address)
              ],
            )),
      ),
    );
  }
}
Special Thanks to

所屬分類

原始碼儲存庫

使用此套件的專案

暫無相關資料。