Giter Club home page Giter Club logo

xyz-city-picker's Introduction

xyz_city_picker

已经迁移至空安全

一个支持地图四级下钻的地址选择器

效果预览

example

如何使用

添加xyz_city_picker

打开pubspec.yaml文件 添加如下代码

  xyz_city_picker : ^2.0.0-nullsafety

添加后打开Terminal,执行 flutter packages get

代码中引入

import 'package:xyz_city_picker/xyz_city_picker.dart';

使用

建议先clone下仓库,查看example目录的示例

必须传入的参数有:

参数 含义 类型
province 选择的省份 Map {'name': '', 'id': ''}
city 选择的城市 Map {'name': '', 'id': ''}
district 选择的区县 Map {'name': '', 'id': ''}
street 选择的街道 Map {'name': '', 'id': ''}

代码使用如下:

GestureDetector(
  behavior: HitTestBehavior.translucent,
  onTap: () => XYZCityPicker.showPicker(
      province: province,
      city: city,
      district: district,
      street: street,
      context: context,
      onChange: (int index, Map checkedItem) {
        switch (index) {
          case 0:
           province = checkedItem;
            break;
          case 1:
          city = checkedItem;
            break;
          case 2:
          district = checkedItem;
            break;
          case 3:
          street = checkedItem;
            break;
        }
        setState(() {});
      }),
  child: Container()
)

onChanged回调函数里面把选择的值带回,onChanged的函数签名如下:

typedef OnChange = Function(int index, Map checkedItem);

其中index0124,分别标识provincecitydistrictstreetcheckedItem则为选择的值.

xyz-city-picker's People

Contributors

xieyezi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.