flutter_pickers 0.0.2
flutter_pickers: ^0.0.2 copied to clipboard

Flutter Android iOS web

Flutter selector class library, including date and time selector (settable range), single selector (can be used for gender, occupation, education, constellation, etc.), city address selector (sub-prov

flutter_pickers #

flutter 选择器类库,包括日期及时间选择器(可设置范围)、单项选择器(可用于性别、职业、学历、星座等)、城市地址选择器(分省级、地级及县级)、数字选择器(可用于年龄、身高、体重、温度等)等…… 欢迎Fork & pr贡献您的代码,大家共同学习

pub package GitHub stars GitHub forks

Getting Started #

导入 #

Depend

dependencies: 
    flutter_pickers: ^0.0.1

Install

$ flutter packages get

文档语言: English | 中文简体

如何使用 #


### 地址选择器 > AddressPicker.showPicker() [区域数据来源](https://github.com/airyland/china-area-data) [请戳我查看demo代码](https://github.com/ewdemo/MainActivity.java) * 支持三级联动 * 支持自定义颜色、大小等样式 * 支持显示 '全部' 选项 * 支持只选择 省市 2级 * 支持查询城市码 * 实时回调

simple use

Widget _checkLocation() {
String initProvince = '四川省', initCity = '成都市', initTown = '双流区';
return InkWell(
    onTap: () {
      AddressPicker.showPicker(
        context,
        initProvince: initProvince,
        initCity: initCity,
        initTown: initTown,
        onConfirm: (p, c, t) {
          setState(() {
            initProvince = p;
            initCity = c;
            initTown = t;
          });
        },
      );
    },
    child: Text('$initProvince - $initCity - $initTown'));
}
  • initTown : 不设置或者设置为null ,不显示区级
  • 城市编码 转 城市名
  • 城市编码 转 城市名

三级选择器动图

二级静态图

更多用法

demo _checkLocation3()

AddressPicker.showPicker(
  context,
  initProvince: locations2[0],
  initCity: locations2[1],
  initTown: locations2[2],
  showTitlebar: true,
  menu: _headMenuView,
  menuHeight: 36.0,
  title: title,
  cancelWidget: _cancelButton,
  commitWidget: _commitButton,
  headDecoration: headDecoration,
  addAllItem: false,
  textColor: Colors.white,
  backgroundColor: Colors.grey[800],
  onConfirm: (p, c, t) {},
);



参数描述默认
initProvince初始化 省''
initCity初始化 市''
initTown初始化 区''
onChanged选择器发生变动 return (String province, String city, String town)null
onConfirm选择器提交 return (String province, String city, String town)null
showTitlebar是否显示头部(确认、取消所在位置)true
menu头部和选择器之间的菜单widget,null:不显示null
menuHeight头部和选择器之间的菜单高度,menu为空时值为036.0
cancelWidget取消按钮-
commitWidget确认按钮-
titlehead 中间的标题widget,null:不显示null
textColor选择器文字颜色black87
backgroundColor选择器背景色white
headDecoration头部Container Decoration 样式BoxDecoration(color: backgroundColor)
addAllItem市、区是否添加 '全部' 选项true

更多方法

/// 根据城市名 查询城市code
List<String> cityCode =  Locations.getTownsCityCode("四川省","成都市","锦江区");
return [510000,510100,510104]  or  [510000,510000]  or [510000]  or  []


/// 通过城市code 查询城市名
List<String> cityName =  Locations.getCityNameByCode("510000","510100","510104");
return [四川省, 成都市, 锦江区]  or  [四川省, 成都市]  or [四川省] or []
0
likes
85
pub points
18%
popularity

Flutter selector class library, including date and time selector (settable range), single selector (can be used for gender, occupation, education, constellation, etc.), city address selector (sub-provincial, prefecture and county level), Digital selector (can be used for age, height, weight, temperature, etc.), etc.... Welcome Fork & pr to contribute your code and learn together

Repository (GitHub)
View/report issues

Documentation

API reference

Uploader

longer413@gmail.com

License

MIT (LICENSE)

Dependencies

flutter

More

Packages that depend on flutter_pickers