city_pickers 0.1.16

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • 98

Language: English

city_pickers #

中国的城市三级联动选择器

Demo #

开始 #

在flutter的项目文件中增加依赖

dependencies:
  ...
    city_pickers:^0.0.1

关于如何运行flutter项目, 参考官方文档documentation.

使用方法 #

Import city_pickers.dart

import 'package:city_pickers/city_pickers.dart';

简单使用方法

...
// type 1
Result result = await CityPickers.showCityPicker(
  context: context,
);
// type 2
Result result2 = await CityPickers.showFullPageCityPicker(
  context: context,
);
// type 3
Result result2 = await CityPickers.showCitiesSelector(
  context: context,
);

注意事项 #

showCitiesSelector 是在版本:0.1.16中刚封装出的功能. 可能存在不稳定或者未知的bug. 欢迎大家使用的时候提出反馈与issue.

CityPickers 静态方法 #

NameTypeDesc
showCityPickerFunction呼出弹出层,显示多级选择器
showFullPageCityPickerFunction呼出一层界面, 显示多级选择器
showCitiesSelectorFunction呼出一层, 显示支持字母定位城市选择器

showCityPicker 参数说明 #

NameTypeDefaultDesc
contextBuildContextnull上下文对象
themeThemeDataTheme.of(context)主题, 可以自定义
locationCodeString110000初始化地址信息, 可以是省, 市, 区的地区码
heightdouble300弹出层的高度, 过高或者过低会导致容器报错
showTypeShowTypeShowType.pca三级联动, 显示类型
barrierOpacitydouble0.5弹出层的背景透明度, 应该是大于0, 小于1
barrierDismissiblebooltrue是否可以通过点击弹出层背景, 关闭弹出层
citiesDataMap城市数据选择器的城市与区的数据源
provincesDataMap省份数据选择器的省份数据源

showFullPageCityPicker 参数说明 #

NameTypeDefaultDesc
contextBuildContextnull上下文对象
themeThemeDataTheme.of(context)主题, 可以自定义
locationCodeString110000初始化地址信息, 可以是省, 市, 区的地区码
showTypeShowTypeShowType.pca三级联动, 显示类型
citiesDataMap城市数据选择器的城市与区的数据源
provincesDataMap省份数据选择器的省份数据源

showCitiesSelector 参数说明 #

NameTypeDefaultDesc
contextBuildContextnull上下文对象
themeThemeDataTheme.of(context)主题, 可以自定义
locationCodeString110000初始化地址信息, 可以是省, 市, 区的地区码
titleString城市选择器弹出层界面标题
citiesDataMap城市数据选择器的城市与区的数据源
provincesDataMap省份数据选择器的省份数据源
sideBarStyleBaseStyle初始默认样式右侧字母索引集样式
cityItemStyleBaseStyle初始默认样式城市选项样式
topStickStyleBaseStyle初始默认样式顶部索引吸顶样式

数据来源 #

National Bureau of Statistics

声明 #

本项目Example部份代码与样式, 参考借鉴Flutter Go, flutter go 是flutter 开发者帮助 APP,包含 flutter 常用 140+ 组件的demo 演示与中文文档

To Do List #

  • [x] 城市选择器, 借鉴点评
  • [ ] 支持拼音等模糊搜索
  • [ ] 加入单元测试

0.1.16 #

  • 增加 showCitiesSelector 函数方法, 城市级选择器. 支持右侧拼音首字母定位

0.1.15 #

  • 解决使用非标准数据源, 导致的省份数据报错的问题

0.1.14 #

  • 解决用户给出的location不正确, 导致的报错

0.1.13 #

  • 更新文档

0.1.12 #

  • 解决自定义数据源, 报错的问题
  • 加入自定义数据源的Example配置

0.1.10 #

  • 优化当市级无选项时的显示逻辑

0.1.9 #

0.1.3 #

  • 更新readme中的效果图

0.1.2 #

  • 加入省市县三级全屏效果
  • 更新文档介绍
  • 完善ios选择器的参数

0.0.1 #

  • 加入三级联动
  • 支持配置高度
  • 支持初始化地理位置

example/README.md

city_pickers_example #

Demonstrates how to use the city_pickers.

Quick test #

flutter run

Specific app entry point #

flutter run -t lib/main.dart

Getting Started #

For help getting started with Flutter, view the online documentation.

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  city_pickers: ^0.1.16

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter packages get

Alternatively, your editor might support flutter packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:city_pickers/city_pickers.dart';
  
Version Uploaded Documentation Archive
0.1.16 Apr 12, 2019 Go to the documentation of city_pickers 0.1.16 Download city_pickers 0.1.16 archive
0.1.15 Apr 11, 2019 Go to the documentation of city_pickers 0.1.15 Download city_pickers 0.1.15 archive
0.1.14 Mar 2, 2019 Go to the documentation of city_pickers 0.1.14 Download city_pickers 0.1.14 archive
0.1.13 Feb 27, 2019 Go to the documentation of city_pickers 0.1.13 Download city_pickers 0.1.13 archive
0.1.12 Feb 26, 2019 Go to the documentation of city_pickers 0.1.12 Download city_pickers 0.1.12 archive
0.1.11 Feb 25, 2019 Go to the documentation of city_pickers 0.1.11 Download city_pickers 0.1.11 archive
0.1.9 Feb 24, 2019 Go to the documentation of city_pickers 0.1.9 Download city_pickers 0.1.9 archive
0.1.8 Feb 21, 2019 Go to the documentation of city_pickers 0.1.8 Download city_pickers 0.1.8 archive
0.1.7 Feb 20, 2019 Go to the documentation of city_pickers 0.1.7 Download city_pickers 0.1.7 archive
0.1.6 Feb 18, 2019 Go to the documentation of city_pickers 0.1.6 Download city_pickers 0.1.6 archive

All 20 versions...

Popularity:
Describes how popular the package is relative to other packages. [more]
96
Health:
Code health derived from static analysis. [more]
99
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
98
Learn more about scoring.

We analyzed this package on Apr 16, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.2.0
  • pana: 0.12.14
  • Flutter: 1.4.7

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Health suggestions

Fix lib/src/cities_selector/alpha.dart. (-1 points)

Analysis of lib/src/cities_selector/alpha.dart reported 2 hints:

line 51 col 23: The value of the field '_alphas' isn't used.

line 102 col 9: The value of the field '_changeTimer' isn't used.

Format lib/modal/point.dart.

Run flutter format to format lib/modal/point.dart.

Format lib/src/city_picker.dart.

Run flutter format to format lib/src/city_picker.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.68.0 <3.0.0
flutter 0.0.0
lpinyin ^1.0.7 1.0.7
Transitive dependencies
collection 1.14.11
meta 1.1.6 1.1.7
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_colorpicker ^0.2.2