Flutter CityPicker


简介

显示中国的省市县地区

通过函数 showCityPicker 调用, 在容器窗口上弹出遮罩层

基本用法

  • locationCode 初始化地区选择
  • height 弹出层高度
  • context 上下文对象

实例演示

import 'package:flutter/material.dart';
import 'package:city_pickers/city_pickers.dart';

class CityPickerDemo extends StatefulWidget {
  _Demo createState() => _Demo();
}

class _Demo extends State<CityPickerDemo> {
  String _result;
  show(context) async {
    Result temp  = await CityPickers.showCityPicker(
      context: context,
//      locationCode: '640221',
      height: 400,
    );
    setState(() {
      _result = "${temp.toString()}";
    });
  }

  Widget build(BuildContext context) {
    return Center(
        child: Column(
          children: <Widget>[
            Text("result: ${_result.toString()}"),
            RaisedButton(
              onPressed: () {this.show(context);
              },
              child: Text("select"),
            ),
          ],
        )
    );
  }
}