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,
);

CityPickers 静态方法

NameTypeDesc
showCityPickerFunction呼出弹出层,显示多级选择器
showFullPageCityPickerFunction呼出一层界面, 显示多级选择器

showCityPicker 参数说明

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

showFullPageCityPicker 参数说明

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

数据来源

National Bureau of Statistics

声明

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

To Do List

  • 城市选择器, 借鉴点评
  • 支持拼音等模糊搜索

Libraries

_province
base_citys
city_pickers
point
province
result

Dart

dart:ui
Built-in types and core primitives for a Flutter application. [...]

Core

dart:async
Support for asynchronous programming, with classes such as Future and Stream. [...]
dart:collection
Classes and utilities that supplement the collection support in dart:core. [...]
dart:convert
Encoders and decoders for converting between different data representations, including JSON and UTF-8. [...]
dart:core
Built-in types, collections, and other core functionality for every Dart program. [...]
dart:developer
Interact with developer tools such as the debugger and inspector. [...]
dart:math
Mathematical constants and functions, plus a random number generator. [...]
dart:typed_data
Lists that efficiently handle fixed sized data (for example, unsigned 8 byte integers) and SIMD numeric types. [...]

VM

dart:io
File, socket, HTTP, and other I/O support for non-web applications. [...]
dart:isolate
Concurrent programming using isolates: independent workers that are similar to threads but don't share memory, communicating only via messages. [...]