Flutter 制作城市选择界面

一、安装依赖
# 生产依赖
dependencies:
  azlistview: ^0.1.2 #选择城市
  lpinyin: ^1.0.7
二、主页面
import 'dart:convert';

import 'package:azlistview/azlistview.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_snsoft/widgets/input/searchinput.dart';
import 'package:lpinyin/lpinyin.dart';

class CityInfo extends ISuspensionBean {
  String name;
  String tagIndex;
  String namePinyin;
  String strings;
  String shrink;
  bool isShowSuspension;
  CityInfo(
      {this.name, this.tagIndex, this.namePinyin, this.shrink, this.strings});

  String getSuspensionTag() {
    return this.tagIndex;
  }

  CityInfo.fromJson(Map<String, dynamic> json)
      : name = json['name'] == null ? "" : json['name'];

  Map<String, dynamic> toJson() => {
        'name': name,
        'tagIndex': tagIndex,
        'namePinyin': namePinyin,
        'isShowSuspension': isShowSuspension
      };

  @override
  String toString() => "CityBean {" + " \"name\":\"" + name + "\"" + '}';
}

class CitySearchPage extends StatefulWidget {
  @override
  State<StatefulWidget> createState() => _CitySearchPageState();
}

class _CitySearchPageState extends State<CitySearchPage> {
  List<CityInfo> _cityList = List();
  List<CityInfo> _hotCityList = List();
  List<CityInfo> _searchList = List();
  TextEditingController _keyword = TextEditingController(text: '');
  int _suspensionHeight = 32;
  int _itemHeight = 48;
  String _suspensionTag = "";
  final TextEditingController cityController = new TextEditingController();

  bool _isSearching = false;
  @override
  void initState() {
    super.initState();
    loadData();
  }

  @override
  void dispose() {
    // TODO: implement dispose
    super.dispose();
  }

  void loadData() async {
    _hotCityList.add(CityInfo(name: "北京市", tagIndex: "★"));
    _hotCityList.add(CityInfo(name: "上海市", tagIndex: "★"));
    _hotCityList.add(CityInfo(name: "广州市", tagIndex: "★"));
    _hotCityList.add(CityInfo(name: "深圳市", tagIndex: "★"));
    _hotCityList.add(CityInfo(name: "杭州市", tagIndex: "★"));
    _hotCityList.add(CityInfo(name: "武汉市", tagIndex: "★"));
    _hotCityList.add(CityInfo(name: "重庆市", tagIndex: "★"));
    _hotCityList.add(CityInfo(name: "大连市", tagIndex: "★"));

    //加载城市列表
    rootBundle.loadString('assets/file/china.json').then((value) {
      Map countyMap = json.decode(value);
      List list = countyMap['china'];
      list.forEach((value) {
        _cityList.add(CityInfo(name: value['name']));
      });
      _handleList(_cityList);
      setState(() {
        _suspensionTag = _hotCityList[0].getSuspensionTag();
      });
    });
  }

  void _handleList(List<CityInfo> list) {
    if (list == null || list.isEmpty) return;
    for (var i = 0; i < list.length; i++) {
      String pinyin = PinyinHelper.getPinyinE(list[i].name);
      String tag = pinyin.substring(0, 1).toUpperCase();
      String shrink = "";
      List<String> strings = pinyin.split(" ");
      strings.forEach((element) {
        shrink += element.substring(0, 1);
      });
      list[i].shrink = shrink;
      list[i].namePinyin = pinyin;
      if (RegExp("[A-Z]").hasMatch(tag)) {
        list[i].tagIndex = tag;
      } else {
        list[i].tagIndex = "#";
      }
    }
    //根据A-Z排序
    SuspensionUtil.sortListBySuspensionTag(list);
  }

  void _onSusTagChanged(String tag) {
    setState(() {
      _suspensionTag = tag;
    });
  }

  Widget _buildSusWidget(String susTag) {
    susTag = (susTag == "★" ? "热门城市" : susTag);
    return Container(
      height: _suspensionHeight.toDouble(),
      padding: const EdgeInsets.only(left: 16.0),
      color: Color(0xfff3f4f5),
      alignment: Alignment.centerLeft,
      child: Text(
        '$susTag',
        softWrap: false,
        style: TextStyle(
          fontSize: 14.0,
          color: Color(0xff999999),
        ),
      ),
    );
  }

  Widget _buildListItem(CityInfo model) {
    String susTag = model.getSuspensionTag();
    susTag = (susTag == "★" ? "热门城市" : susTag);
    return Column(
      children: <Widget>[
        Offstage(
          offstage: model.isShowSuspension != true,
          child: _buildSusWidget(susTag),
        ),
        Container(
          decoration: BoxDecoration(
              color: Colors.white,
              border: Border(
                  bottom: BorderSide(width: 0.5, color: Color(0xffe7e7e7)))),
          height: _itemHeight.toDouble(),
          alignment: Alignment.centerLeft,
          padding: EdgeInsets.only(left: 16),
          width: double.infinity,
          child: GestureDetector(
            onTap: () {
              Navigator.pop(context, model.name);
            },
            child: Text(model.name),
          ),
        )
      ],
    );
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        resizeToAvoidBottomPadding: false, //键盘弹起是不向上推页面
        appBar: AppBar(
          title: const Text('城市选择'),
          centerTitle: true,
          bottom: PreferredSize(
            preferredSize: const Size.fromHeight(42.0),
            child: Container(
              color: Colors.white,
              padding: EdgeInsets.symmetric(horizontal: 16, vertical: 10),
              child: SearchInput(
                textEditingController: _keyword,
                readonly: true,
                placeholder: "搜索国家",
                showBtn: false,
                height: 36,
                iconSize: 20,
                hintStyle: TextStyle(color: Color(0xffBDBDBD)),
              ),
            ),
          ),
        ),
        body: Stack(
          children: <Widget>[
            Offstage(
              offstage: !_isSearching,
              child: ListView.separated(
                itemCount: _searchList.length == 0 ? 1 : _searchList.length,
                itemBuilder: (context, index) {
                  if (_searchList.length > 0) {
                    return ListTile(
                      title: Text(_searchList[index].name),
                      onTap: () {
                        Navigator.pop(context, _searchList[index].name);
                      },
                    );
                  } else {
                    return Container(
                      margin: EdgeInsets.only(top: 40.0),
                      child: Center(
                        child: Text(
                          "无法查询到城市",
                          style: TextStyle(fontSize: 16.0, color: Colors.grey),
                        ),
                      ),
                    );
                  }
                },
                separatorBuilder: (context, index) {
                  return Divider(height: 0.0, thickness: 0.0, indent: 0);
                },
              ),
            ),
            Offstage(
              offstage: _isSearching,
              child: Column(
                children: <Widget>[
                  Container(
                    alignment: Alignment.centerLeft,
                    padding: const EdgeInsets.only(left: 15.0),
                    height: 28.0,
                    child: Text(
                      "当前位置",
                      style: TextStyle(fontSize: 14, color: Color(0xff999999)),
                    ),
                  ),
                  InkWell(
                    onTap: () {
                      Navigator.pop(context, '北京市');
                    },
                    child: Container(
                      height: 44.0,
                      color: Colors.white,
                      padding: EdgeInsets.only(left: 16),
                      child: Row(
                        children: [
                          Image.asset('assets/icons/map-pin.png'),
                          Container(
                            margin: EdgeInsets.only(left: 10),
                            child: Text('北京市'),
                          )
                        ],
                      ),
                    ),
                  ),
                  Expanded(
                    flex: 1,
                    child: AzListView(
                      data: _cityList,
                      topData: _hotCityList,
                      itemBuilder: (context, model) => _buildListItem(model),
                      // suspensionWidget: _buildSusWidget(_suspensionTag),
                      itemHeight: _itemHeight,
                      suspensionHeight: _suspensionHeight,
                      onSusTagChanged: _onSusTagChanged,
                      showIndexHint: true,
                    ),
                  ),
                ],
              ),
            ),
          ],
        ));
  }
}

json数据

三、城市json数据
{
    "china": [
      {
        "name": "全部城市"
      },
      {
        "name": "北京市"
      },
      {
        "name": "天津市"
      },
      {
        "name": "河北省"
      },
      {
        "name": "石家庄市"
      },
      {
        "name": "唐山市"
      },
      {
        "name": "秦皇岛市"
      },
      {
        "name": "邯郸市"
      },
      {
        "name": "邢台市"
      },
      {
        "name": "保定市"
      },
      {
        "name": "张家口市"
      },
      {
        "name": "承德市"
      },
      {
        "name": "沧州市"
      },
      {
        "name": "廊坊市"
      },
      {
        "name": "衡水市"
      },
      {
        "name": "山西省"
      },
      {
        "name": "太原市"
      },
      {
        "name": "大同市"
      },
      {
        "name": "阳泉市"
      },
      {
        "name": "长治市"
      },
      {
        "name": "晋城市"
      },
      {
        "name": "朔州市"
      },
      {
        "name": "晋中市"
      },
      {
        "name": "运城市"
      },
      {
        "name": "忻州市"
      },
      {
        "name": "临汾市"
      },
      {
        "name": "吕梁市"
      },
      {
        "name": "内蒙古省"
      },
      {
        "name": "呼和浩特市"
      },
      {
        "name": "包头市"
      },
      {
        "name": "乌海市"
      },
      {
        "name": "赤峰市"
      },
      {
        "name": "通辽市"
      },
      {
        "name": "鄂尔多斯市"
      },
      {
        "name": "呼伦贝尔市"
      },
      {
        "name": "巴彦淖尔市"
      },
      {
        "name": "乌兰察布市"
      },
      {
        "name": "兴安盟"
      },
      {
        "name": "锡林郭勒盟"
      },
      {
        "name": "阿拉善盟"
      },
      {
        "name": "沈阳市"
      },
      {
        "name": "大连市"
      },
      {
        "name": "鞍山市"
      },
      {
        "name": "抚顺市"
      },
      {
        "name": "本溪市"
      },
      {
        "name": "丹东市"
      },
      {
        "name": "锦州市"
      },
      {
        "name": "营口市"
      },
      {
        "name": "阜新市"
      },
      {
        "name": "辽阳市"
      },
      {
        "name": "盘锦市"
      },
      {
        "name": "铁岭市"
      },
      {
        "name": "朝阳市"
      },
      {
        "name": "葫芦岛市"
      },
      {
        "name": "长春市"
      },
      {
        "name": "吉林市"
      },
      {
        "name": "四平市"
      },
      {
        "name": "辽源市"
      },
      {
        "name": "通化市"
      },
      {
        "name": "白山市"
      },
      {
        "name": "松原市"
      },
      {
        "name": "白城市"
      },
      {
        "name": "延边朝鲜族自治州"
      },
      {
        "name": "哈尔滨市"
      },
      {
        "name": "齐齐哈尔市"
      },
      {
        "name": "鸡西市"
      },
      {
        "name": "鹤岗市"
      },
      {
        "name": "双鸭山市"
      },
      {
        "name": "大庆市"
      },
      {
        "name": "伊春市"
      },
      {
        "name": "佳木斯市"
      },
      {
        "name": "七台河市"
      },
      {
        "name": "牡丹江市"
      },
      {
        "name": "黑河市"
      },
      {
        "name": "绥化市"
      },
      {
        "name": "大兴安岭地区"
      },
      {
        "name": "上海市"
      },
      {
        "name": "南京市"
      },
      {
        "name": "无锡市"
      },
      {
        "name": "徐州市"
      },
      {
        "name": "常州市"
      },
      {
        "name": "苏州市"
      },
      {
        "name": "南通市"
      },
      {
        "name": "连云港市"
      },
      {
        "name": "淮安市"
      },
      {
        "name": "盐城市"
      },
      {
        "name": "扬州市"
      },
      {
        "name": "镇江市"
      },
      {
        "name": "泰州市"
      },
      {
        "name": "宿迁市"
      },
      {
        "name": "杭州市"
      },
      {
        "name": "宁波市"
      },
      {
        "name": "温州市"
      },
      {
        "name": "嘉兴市"
      },
      {
        "name": "湖州市"
      },
      {
        "name": "绍兴市"
      },
      {
        "name": "金华市"
      },
      {
        "name": "衢州市"
      },
      {
        "name": "舟山市"
      },
      {
        "name": "台州市"
      },
      {
        "name": "丽水市"
      },
      {
        "name": "合肥市"
      },
      {
        "name": "芜湖市"
      },
      {
        "name": "蚌埠市"
      },
      {
        "name": "淮南市"
      },
      {
        "name": "马鞍山市"
      },
      {
        "name": "淮北市"
      },
      {
        "name": "铜陵市"
      },
      {
        "name": "安庆市"
      },
      {
        "name": "黄山市"
      },
      {
        "name": "滁州市"
      },
      {
        "name": "阜阳市"
      },
      {
        "name": "宿州市"
      },
      {
        "name": "巢湖市"
      },
      {
        "name": "六安市"
      },
      {
        "name": "亳州市"
      },
      {
        "name": "池州市"
      },
      {
        "name": "宣城市"
      },
      {
        "name": "福州市"
      },
      {
        "name": "厦门市"
      },
      {
        "name": "莆田市"
      },
      {
        "name": "三明市"
      },
      {
        "name": "泉州市"
      },
      {
        "name": "漳州市"
      },
      {
        "name": "南平市"
      },
      {
        "name": "龙岩市"
      },
      {
        "name": "宁德市"
      },
      {
        "name": "南昌市"
      },
      {
        "name": "景德镇市"
      },
      {
        "name": "萍乡市"
      },
      {
        "name": "九江市"
      },
      {
        "name": "新余市"
      },
      {
        "name": "鹰潭市"
      },
      {
        "name": "赣州市"
      },
      {
        "name": "吉安市"
      },
      {
        "name": "宜春市"
      },
      {
        "name": "抚州市"
      },
      {
        "name": "上饶市"
      },
      {
        "name": "济南市"
      },
      {
        "name": "青岛市"
      },
      {
        "name": "淄博市"
      },
      {
        "name": "枣庄市"
      },
      {
        "name": "东营市"
      },
      {
        "name": "烟台市"
      },
      {
        "name": "潍坊市"
      },
      {
        "name": "济宁市"
      },
      {
        "name": "泰安市"
      },
      {
        "name": "威海市"
      },
      {
        "name": "日照市"
      },
      {
        "name": "莱芜市"
      },
      {
        "name": "临沂市"
      },
      {
        "name": "德州市"
      },
      {
        "name": "聊城市"
      },
      {
        "name": "滨州市"
      },
      {
        "name": "菏泽市"
      },
      {
        "name": "郑州市"
      },
      {
        "name": "开封市"
      },
      {
        "name": "洛阳市"
      },
      {
        "name": "平顶山市"
      },
      {
        "name": "安阳市"
      },
      {
        "name": "鹤壁市"
      },
      {
        "name": "新乡市"
      },
      {
        "name": "焦作市"
      },
      {
        "name": "濮阳市"
      },
      {
        "name": "许昌市"
      },
      {
        "name": "漯河市"
      },
      {
        "name": "三门峡市"
      },
      {
        "name": "南阳市"
      },
      {
        "name": "商丘市"
      },
      {
        "name": "信阳市"
      },
      {
        "name": "周口市"
      },
      {
        "name": "驻马店市"
      },
      {
        "name": "武汉市"
      },
      {
        "name": "黄石市"
      },
      {
        "name": "十堰市"
      },
      {
        "name": "宜昌市"
      },
      {
        "name": "襄樊市"
      },
      {
        "name": "鄂州市"
      },
      {
        "name": "荆门市"
      },
      {
        "name": "孝感市"
      },
      {
        "name": "荆州市"
      },
      {
        "name": "黄冈市"
      },
      {
        "name": "咸宁市"
      },
      {
        "name": "随州市"
      },
      {
        "name": "恩施土家族苗族自治州"
      },
      {
        "name": "仙桃市"
      },
      {
        "name": "潜江市"
      },
      {
        "name": "天门市"
      },
      {
        "name": "神农架林区"
      },
      {
        "name": "长沙市"
      },
      {
        "name": "株洲市"
      },
      {
        "name": "湘潭市"
      },
      {
        "name": "衡阳市"
      },
      {
        "name": "邵阳市"
      },
      {
        "name": "岳阳市"
      },
      {
        "name": "常德市"
      },
      {
        "name": "张家界市"
      },
      {
        "name": "益阳市"
      },
      {
        "name": "郴州市"
      },
      {
        "name": "永州市"
      },
      {
        "name": "怀化市"
      },
      {
        "name": "娄底市"
      },
      {
        "name": "湘西土家族苗族自治州"
      },
      {
        "name": "广州市"
      },
      {
        "name": "韶关市"
      },
      {
        "name": "深圳市"
      },
      {
        "name": "珠海市"
      },
      {
        "name": "汕头市"
      },
      {
        "name": "佛山市"
      },
      {
        "name": "江门市"
      },
      {
        "name": "湛江市"
      },
      {
        "name": "茂名市"
      },
      {
        "name": "肇庆市"
      },
      {
        "name": "惠州市"
      },
      {
        "name": "梅州市"
      },
      {
        "name": "汕尾市"
      },
      {
        "name": "河源市"
      },
      {
        "name": "阳江市"
      },
      {
        "name": "清远市"
      },
      {
        "name": "东莞市"
      },
      {
        "name": "中山市"
      },
      {
        "name": "潮州市"
      },
      {
        "name": "揭阳市"
      },
      {
        "name": "云浮市"
      },
      {
        "name": "南宁市"
      },
      {
        "name": "柳州市"
      },
      {
        "name": "桂林市"
      },
      {
        "name": "梧州市"
      },
      {
        "name": "北海市"
      },
      {
        "name": "防城港市"
      },
      {
        "name": "钦州市"
      },
      {
        "name": "贵港市"
      },
      {
        "name": "玉林市"
      },
      {
        "name": "百色市"
      },
      {
        "name": "贺州市"
      },
      {
        "name": "河池市"
      },
      {
        "name": "来宾市"
      },
      {
        "name": "崇左市"
      },
      {
        "name": "海口市"
      },
      {
        "name": "三亚市"
      },
      {
        "name": "重庆市"
      },
      {
        "name": "成都市"
      },
      {
        "name": "自贡市"
      },
      {
        "name": "攀枝花市"
      },
      {
        "name": "泸州市"
      },
      {
        "name": "德阳市"
      },
      {
        "name": "绵阳市"
      },
      {
        "name": "广元市"
      },
      {
        "name": "遂宁市"
      },
      {
        "name": "内江市"
      },
      {
        "name": "乐山市"
      },
      {
        "name": "南充市"
      },
      {
        "name": "眉山市"
      },
      {
        "name": "宜宾市"
      },
      {
        "name": "广安市"
      },
      {
        "name": "达州市"
      },
      {
        "name": "雅安市"
      },
      {
        "name": "巴中市"
      },
      {
        "name": "资阳市"
      },
      {
        "name": "阿坝藏族羌族自治州"
      },
      {
        "name": "甘孜藏族自治州"
      },
      {
        "name": "凉山彝族自治州"
      },
      {
        "name": "贵阳市"
      },
      {
        "name": "六盘水市"
      },
      {
        "name": "遵义市"
      },
      {
        "name": "安顺市"
      },
      {
        "name": "铜仁市"
      },
      {
        "name": "黔西南布依族苗族自治州"
      },
      {
        "name": "毕节市"
      },
      {
        "name": "黔东南苗族侗族自治州"
      },
      {
        "name": "黔南布依族苗族自治州"
      },
      {
        "name": "昆明市"
      },
      {
        "name": "曲靖市"
      },
      {
        "name": "玉溪市"
      },
      {
        "name": "保山市"
      },
      {
        "name": "昭通市"
      },
      {
        "name": "丽江市"
      },
      {
        "name": "思茅市"
      },
      {
        "name": "临沧市"
      },
      {
        "name": "楚雄彝族自治州"
      },
      {
        "name": "红河哈尼族彝族自治州"
      },
      {
        "name": "文山壮族苗族自治州"
      },
      {
        "name": "西双版纳傣族自治州"
      },
      {
        "name": "大理白族自治州"
      },
      {
        "name": "德宏傣族景颇族自治州"
      },
      {
        "name": "怒江傈僳族自治州"
      },
      {
        "name": "迪庆藏族自治州"
      },
      {
        "name": "拉萨市"
      },
      {
        "name": "昌都地区"
      },
      {
        "name": "山南地区"
      },
      {
        "name": "日喀则地区"
      },
      {
        "name": "那曲地区"
      },
      {
        "name": "阿里地区"
      },
      {
        "name": "林芝地区"
      },
      {
        "name": "西安市"
      },
      {
        "name": "铜川市"
      },
      {
        "name": "宝鸡市"
      },
      {
        "name": "咸阳市"
      },
      {
        "name": "渭南市"
      },
      {
        "name": "延安市"
      },
      {
        "name": "汉中市"
      },
      {
        "name": "榆林市"
      },
      {
        "name": "安康市"
      },
      {
        "name": "商洛市"
      },
      {
        "name": "兰州市"
      },
      {
        "name": "嘉峪关市"
      },
      {
        "name": "金昌市"
      },
      {
        "name": "白银市"
      },
      {
        "name": "天水市"
      },
      {
        "name": "武威市"
      },
      {
        "name": "张掖市"
      },
      {
        "name": "平凉市"
      },
      {
        "name": "酒泉市"
      },
      {
        "name": "庆阳市"
      },
      {
        "name": "定西市"
      },
      {
        "name": "陇南市"
      },
      {
        "name": "临夏回族自治州"
      },
      {
        "name": "甘南藏族自治州"
      },
      {
        "name": "西宁市"
      },
      {
        "name": "海东地区"
      },
      {
        "name": "海北藏族自治州"
      },
      {
        "name": "黄南藏族自治州"
      },
      {
        "name": "海南藏族自治州"
      },
      {
        "name": "果洛藏族自治州"
      },
      {
        "name": "玉树藏族自治州"
      },
      {
        "name": "海西蒙古族藏族自治州"
      },
      {
        "name": "银川市"
      },
      {
        "name": "石嘴山市"
      },
      {
        "name": "吴忠市"
      },
      {
        "name": "固原市"
      },
      {
        "name": "中卫市"
      },
      {
        "name": "乌鲁木齐市"
      },
      {
        "name": "克拉玛依市"
      },
      {
        "name": "吐鲁番地区"
      },
      {
        "name": "哈密地区"
      },
      {
        "name": "昌吉回族自治州"
      },
      {
        "name": "博尔塔拉蒙古自治州"
      },
      {
        "name": "巴音郭楞蒙古自治州"
      },
      {
        "name": "阿克苏地区"
      },
      {
        "name": "克孜勒苏柯尔克孜自治州"
      },
      {
        "name": "喀什地区"
      },
      {
        "name": "和田地区"
      },
      {
        "name": "伊犁哈萨克"
      },
      {
        "name": "塔城地区"
      },
      {
        "name": "阿勒泰地区"
      },
      {
        "name": "石河子市"
      },
      {
        "name": "阿拉尔市"
      },
      {
        "name": "图木舒克市"
      },
      {
        "name": "五家渠市"
      },
      {
        "name": "台北"
      },
      {
        "name": "高雄"
      },
      {
        "name": "基隆"
      },
      {
        "name": "台中"
      },
      {
        "name": "台南"
      },
      {
        "name": "新竹"
      },
      {
        "name": "嘉义"
      },
      {
        "name": "宜兰"
      },
      {
        "name": "桃园"
      },
      {
        "name": "苗栗"
      },
      {
        "name": "彰化"
      },
      {
        "name": "南投"
      },
      {
        "name": "云林"
      },
      {
        "name": "屏东"
      },
      {
        "name": "台东"
      },
      {
        "name": "花莲"
      },
      {
        "name": "澎湖"
      },
      {
        "name": "香港岛"
      },
      {
        "name": "九龙"
      },
      {
        "name": "新界"
      },
      {
        "name": "澳门半岛"
      },
      {
        "name": "氹仔岛"
      },
      {
        "name": "路环岛"
      },
      {
        "name": "路氹城"
      }
    ]
  }

我自己的代码

import 'dart:convert';
import 'dart:ui';

import 'package:azlistview/azlistview.dart';
import 'package:dio/dio.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:lpinyin/lpinyin.dart';
import 'package:shared_preferences/shared_preferences.dart';

import 'DialogRouter.dart';
import 'LoadingDialog.dart';
import 'data/ModifyBaseInfo.dart';

/**
 * 自定义坐标dialog
 */
// class CustomizeDialog extends Dialog {
//   //点击背景是否能够退出
//   final bool canceledOnTouchOutside;
//
//   // CustomizeDialog({
//   //   Key key,
//   // }) : super(key: key);
//   CustomizeDialog(this.canceledOnTouchOutside) : super();
//
//   @override
//   Widget build(BuildContext context) {
//     return MaterialApp(home: LoginRoute(canceledOnTouchOutside));
//   }
// }

//用Dialog问题太多了,直接用界面算了
class AreaSelector extends StatefulWidget {
  AreaSelector({key, this.canceledOnTouchOutside}) : super(key: key);
  // const LoginRoute(this.canceledOnTouchOutside) : super();
  final bool canceledOnTouchOutside;

  @override
  //状态
  AreaSelectorState createState() => AreaSelectorState(canceledOnTouchOutside);
}

//Json解析类
class CityInfo extends ISuspensionBean {
  String name;
  String tagIndex;
  String namePinyin;
  String strings;
  String shrink;
  bool isShowSuspension;

  CityInfo(
      {this.name, this.tagIndex, this.namePinyin, this.shrink, this.strings});

  String getSuspensionTag() {
    return this.tagIndex;
  }

  CityInfo.fromJson(Map<String, dynamic> json)
      : name = json['name'] == null ? "" : json['name'];

  Map<String, dynamic> toJson() => {
        'name': name,
        'tagIndex': tagIndex,
        'namePinyin': namePinyin,
        'isShowSuspension': isShowSuspension
      };

  @override
  String toString() => "CityBean {" + " \"name\":\"" + name + "\"" + '}';
}

class AreaSelectorState extends State<AreaSelector> {
  AreaSelectorState(bool canceledOnTouchOutside1);

  List<CityInfo> _cityList = List();
  // List<CityInfo> _hotCityList = List();
  List<CityInfo> _searchList = List();
  TextEditingController _keyword = TextEditingController(text: '');
  int _suspensionHeight = 32;
  int _itemHeight = 48;
  String _suspensionTag = "";
  final TextEditingController cityController = new TextEditingController();

  bool _isSearching = false;
  String mArea = "null";

  @override
  void initState() {
    super.initState();
    loadData();
  }

  void loadData() async {
    // _hotCityList.add(CityInfo(name: "北京市", tagIndex: "★"));
    // _hotCityList.add(CityInfo(name: "上海市", tagIndex: "★"));
    // _hotCityList.add(CityInfo(name: "广州市", tagIndex: "★"));
    // _hotCityList.add(CityInfo(name: "深圳市", tagIndex: "★"));
    // _hotCityList.add(CityInfo(name: "杭州市", tagIndex: "★"));
    // _hotCityList.add(CityInfo(name: "武汉市", tagIndex: "★"));
    // _hotCityList.add(CityInfo(name: "重庆市", tagIndex: "★"));
    // _hotCityList.add(CityInfo(name: "大连市", tagIndex: "★"));

    //加载城市列表
    rootBundle.loadString('lib/data/area_code.json').then((value) {
      Map countyMap = json.decode(value);
      List list = countyMap['lists'];
      list.forEach((value) {
        _cityList.add(CityInfo(name: value['cn']));
      });
      _handleList(_cityList);
      setState(() {
        // _suspensionTag = _hotCityList[0].getSuspensionTag();
      });
    });
  }

  void _handleList(List<CityInfo> list) {
    if (list == null || list.isEmpty) return;
    for (var i = 0; i < list.length; i++) {
      String pinyin = PinyinHelper.getPinyinE(list[i].name);
      String tag = pinyin.substring(0, 1).toUpperCase();
      String shrink = "";
      List<String> strings = pinyin.split(" ");
      strings.forEach((element) {
        shrink += element.substring(0, 1);
      });
      list[i].shrink = shrink;
      list[i].namePinyin = pinyin;
      if (RegExp("[A-Z]").hasMatch(tag)) {
        list[i].tagIndex = tag;
      } else {
        list[i].tagIndex = "#";
      }
    }
    //根据A-Z排序
    SuspensionUtil.sortListBySuspensionTag(list);
  }

  void _onSusTagChanged(String tag) {
    setState(() {
      _suspensionTag = tag;
    });
  }

  Widget _buildSusWidget(String susTag) {
    susTag = (susTag == "★" ? "热门城市" : susTag);
    return Container(
      height: _suspensionHeight.toDouble(),
      padding: const EdgeInsets.only(left: 16.0),
      color: Color(0xfff3f4f5),
      alignment: Alignment.centerLeft,
      child: Text(
        '$susTag',
        softWrap: false,
        style: TextStyle(
          fontSize: 14.0,
          color: Color(0xff999999),
        ),
      ),
    );
  }

  Widget _buildListItem(CityInfo model,context) {
    String susTag = model.getSuspensionTag();
    susTag = (susTag == "★" ? "热门城市" : susTag);
    return Column(
      children: <Widget>[
        // Offstage(
        //   offstage: model.isShowSuspension != true,
        //   child: _buildSusWidget(susTag),
        // ),
        GestureDetector(
          onTap: () {
            setState(() {
              mArea=model.name;
            });
          },
          child:Container(
            decoration: BoxDecoration(
                color: Color(0xFF333333),
               ),
            height: _itemHeight.toDouble(),
            alignment: Alignment.centerLeft,
            padding: EdgeInsets.only(left: 16),
            width: double.infinity,
              child: Text(model.name,style: TextStyle(color: Color(0xFFDDDDDD)),),
          ),
        ),
      ],
    );
  }

  @override
  void dispose() {
    // TODO: implement dispose
    super.dispose();
  }

  //取屏幕最大宽度和高度
  final width = window.physicalSize.width;
  final height = window.physicalSize.height;

  bool taiPeiPressed = false;
  bool newTaipeiPressed = false;
  bool keeLungPressed = false;
  bool yiLanPressed = false;

  bool taoYuanPressed = false;
  bool xinZuPressed = false;
  bool jiaMeiPressed = false;
  bool taiNanPressed = false;

  bool taiChungPressed = false;
  bool pingTungPressed = false;
  bool penHuPressed = false;
  bool miaoLiPressed = false;

  bool taiZhongPressed = false;
  bool changHuaPressed = false;
  bool nanTouPressed = false;
  bool yunLinPressed = false;

  bool huaLienPressed = false;
  bool taiDongPressed = false;
  bool kinMenPressed = false;
  bool lianJiangPressed = false;

  //更改个人信息接口
  modifySex() async {
    var apiUrl = "http://47.242.63.216:9527/v1/user";

    SharedPreferences prefs = await SharedPreferences.getInstance();
    var tokens = prefs.getString("token");

    //参数
    Map map = {};
    //地区从输入框里面获取
    map["area"] = mArea;

    //网络请求添加token请求头
    Response result = await Dio().post(apiUrl,
        data: map, options: Options(headers: {"x-token": tokens}));
    debugPrint("${result}");

    //json解析
    Map<String, dynamic> nickname = json.decode(result.toString());
    var httpRes = ModifyBaseInfo.fromJson(nickname);
    //如果成功就吐司
    if (httpRes.code == 200) {
      Fluttertoast.showToast(
          msg: "坐標修改成功",
          toastLength: Toast.LENGTH_SHORT,
          gravity: ToastGravity.CENTER,
          timeInSecForIosWeb: 10,
          backgroundColor: Colors.white,
          textColor: Colors.black,
          fontSize: 16.0);
      //返回个人档案界面
      Navigator.pop(context);
      Navigator.pop(context);
    }
  }

  //弹窗也是一个Widget,弹框就是打开一个新的路由,且颜色变成透明色
  @override
  Widget build(BuildContext context) {
    return StatefulBuilder(
      builder: (BuildContext context, void Function(void Function()) setState) {
        return Center(
          child: Material(
              //背景透明
              color: Colors.transparent,
              //保证控件居中效果
              child: Stack(
                children: <Widget>[
                  GestureDetector(
                    //点击事件
                    onTap: () {
                      // if (canceledOnTouchOutside) {
                      //   Navigator.pop(context);
                      // }
                    },
                  ),
                  _dialog(context, setState)
                ],
              )),
        );
      },
    );
  }

  Widget _dialog(context, setState) {
    return Center(
      ///弹框大小
      child: Container(
        width: width,
        height: height,
        margin: EdgeInsets.only(top: 200),
        child: Container(
            ///弹框背景和圆角
            decoration: ShapeDecoration(
              color: Color(0xFF333333),
              shape: RoundedRectangleBorder(
                borderRadius: BorderRadius.all(
                  Radius.circular(8.0),
                ),
              ),
            ),
            child: Stack(
              children: <Widget>[
                Offstage(
                  offstage: !_isSearching,
                  child: ListView.separated(
                    itemCount: _searchList.length == 0 ? 1 : _searchList.length,
                    itemBuilder: (context, index) {
                      if (_searchList.length > 0) {
                        return ListTile(
                          title: Text(_searchList[index].name),
                          onTap: () {
                            Navigator.pop(context, _searchList[index].name);
                          },
                        );
                      } else {
                        return Container(
                          margin: EdgeInsets.only(top: 40.0),
                          child: Center(
                            child: Text(
                              "无法查询到城市",
                              style:
                                  TextStyle(fontSize: 16.0, color: Colors.grey),
                            ),
                          ),
                        );
                      }
                    },
                    separatorBuilder: (context, index) {
                      return Divider(height: 0.0, thickness: 0.0, indent: 0);
                    },
                  ),
                ),
                Offstage(
                  offstage: _isSearching,
                  child: Column(
                    children: <Widget>[
                      Column(
                        // mainAxisAlignment: MainAxisAlignment.spaceEvenly,
                        // crossAxisAlignment: CrossAxisAlignment.center,
                        children: <Widget>[
                          Row(
                            children: [
                              Expanded(
                                  child: Container(
                                margin: EdgeInsets.only(left: 15, bottom: 21,top: 20),
                                child: Text(
                                  "台灣",
                                  style: TextStyle(
                                      color: Color(0xFFDDDDDD), fontSize: 19),
                                ),
                              )),
                              GestureDetector(
                                onTap: () {
                                  //弹窗
                                  Navigator.push(context,
                                      DialogRouter(LoadingDialog(true)));
                                  if (taiPeiPressed) {
                                    setState(() {
                                      mArea = "台北市";
                                      modifySex();
                                    });
                                  } else if (newTaipeiPressed) {
                                    setState(() {
                                      mArea = "新北市";
                                      modifySex();
                                    });
                                  } else if (keeLungPressed) {
                                    setState(() {
                                      mArea = "基隆市";
                                      modifySex();
                                    });
                                  } else if (yiLanPressed) {
                                    setState(() {
                                      mArea = "依蘭縣";
                                      modifySex();
                                    });
                                  } else if (taoYuanPressed) {
                                    setState(() {
                                      mArea = "桃源縣";
                                      modifySex();
                                    });
                                  } else if (xinZuPressed) {
                                    setState(() {
                                      mArea = "新竹縣";
                                      modifySex();
                                    });
                                  } else if (jiaMeiPressed) {
                                    setState(() {
                                      mArea = "嘉美市";
                                      modifySex();
                                    });
                                  } else if (taiNanPressed) {
                                    setState(() {
                                      mArea = "台南市";
                                      modifySex();
                                    });
                                  } else if (taiChungPressed) {
                                    setState(() {
                                      mArea = "臺中市";
                                      modifySex();
                                    });
                                  } else if (pingTungPressed) {
                                    setState(() {
                                      mArea = "屏東縣";
                                      modifySex();
                                    });
                                  } else if (penHuPressed) {
                                    setState(() {
                                      mArea = "澎湖縣";
                                      modifySex();
                                    });
                                  } else if (miaoLiPressed) {
                                    setState(() {
                                      mArea = "苗栗縣";
                                      modifySex();
                                    });
                                  } else if (taiZhongPressed) {
                                    setState(() {
                                      mArea = "台中市";
                                      modifySex();
                                    });
                                  } else if (changHuaPressed) {
                                    setState(() {
                                      mArea = "彰化縣";
                                      modifySex();
                                    });
                                  } else if (nanTouPressed) {
                                    setState(() {
                                      mArea = "南投縣";
                                      modifySex();
                                    });
                                  } else if (yunLinPressed) {
                                    setState(() {
                                      mArea = "雲林縣";
                                      modifySex();
                                    });
                                  } else if (huaLienPressed) {
                                    setState(() {
                                      mArea = "花蓮縣";
                                      modifySex();
                                    });
                                  } else if (taiDongPressed) {
                                    setState(() {
                                      mArea = "台東縣";
                                      modifySex();
                                    });
                                  } else if (kinMenPressed) {
                                    setState(() {
                                      mArea = "金門縣";
                                      modifySex();
                                    });
                                  } else if (lianJiangPressed) {
                                    setState(() {
                                      mArea = "連江縣";
                                      modifySex();
                                    });
                                  }else if(mArea!="null"){
                                    modifySex();
                                  }else if(mArea=="null"){
                                    Navigator.pop(context);
                                    Fluttertoast.showToast(
                                        msg: "请选择坐標",
                                        toastLength: Toast.LENGTH_SHORT,
                                        gravity: ToastGravity.CENTER,
                                        timeInSecForIosWeb: 10,
                                        backgroundColor: Colors.white,
                                        textColor: Colors.black,
                                        fontSize: 16.0);
                                  }
                                },
                                child: Container(
                                  margin:
                                      EdgeInsets.only(right: 15, bottom: 21,top: 20),
                                  child: Text(
                                    "確定",
                                    style: TextStyle(
                                        color: Color(0xFFDDDDDD), fontSize: 19),
                                  ),
                                ),
                              ),
                            ],
                          ),
                          Row(
                            mainAxisAlignment: MainAxisAlignment.spaceEvenly,
                            children: [
                              //台北市
                              GestureDetector(
                                onTap: () {
                                  // Navigator.pop(context, "台北市");
                                  setState(() {
                                    taiPeiPressed = !taiPeiPressed;
                                    if (taiPeiPressed) {
                                      newTaipeiPressed = false;
                                      keeLungPressed = false;
                                      yiLanPressed = false;

                                      taoYuanPressed = false;
                                      xinZuPressed = false;
                                      jiaMeiPressed = false;
                                      taiNanPressed = false;

                                      taiChungPressed = false;
                                      pingTungPressed = false;
                                      penHuPressed = false;
                                      miaoLiPressed = false;

                                      taiZhongPressed = false;
                                      changHuaPressed = false;
                                      nanTouPressed = false;
                                      yunLinPressed = false;

                                      huaLienPressed = false;
                                      taiDongPressed = false;
                                      kinMenPressed = false;
                                      lianJiangPressed = false;
                                    }
                                  });
                                },
                                child: Container(
                                  padding: EdgeInsets.only(left: 10, right: 10),
                                  decoration: taiPeiPressed
                                      ? BoxDecoration(
                                          color: Color(0xFF444444),
                                          borderRadius: BorderRadius.all(
                                            Radius.circular(50),
                                          ))
                                      : BoxDecoration(),
                                  child: Row(
                                    children: [
                                      Container(
                                        height: 20,
                                        width: 14,
                                        margin: EdgeInsets.only(right: 3),
                                        decoration: taiPeiPressed
                                            ? BoxDecoration(
                                                image: DecorationImage(
                                                  image: AssetImage(
                                                      "assets/base_widgets/icon_personal_file_coordinate.png"),
                                                  fit: BoxFit.fitWidth,
                                                ),
                                              )
                                            : BoxDecoration(),
                                      ),
                                      Container(
                                        padding: EdgeInsets.only(
                                            top: 11, bottom: 11),
                                        child: Text(
                                          "台北市",
                                          style: taiPeiPressed
                                              ? TextStyle(
                                                  color: Color(0xFFE6CFA1),
                                                  fontSize: 14)
                                              : TextStyle(
                                                  color: Color(0xFFDDDDDD),
                                                  fontSize: 14),
                                        ),
                                      ),
                                    ],
                                  ),
                                ),
                              ),
                              //新北市
                              GestureDetector(
                                onTap: () {
                                  // Navigator.pop(context, "台北市");
                                  setState(() {
                                    newTaipeiPressed = !newTaipeiPressed;

                                    if (newTaipeiPressed) {
                                      taiPeiPressed = false;
                                      keeLungPressed = false;
                                      yiLanPressed = false;

                                      taoYuanPressed = false;
                                      xinZuPressed = false;
                                      jiaMeiPressed = false;
                                      taiNanPressed = false;

                                      taiChungPressed = false;
                                      pingTungPressed = false;
                                      penHuPressed = false;
                                      miaoLiPressed = false;

                                      taiZhongPressed = false;
                                      changHuaPressed = false;
                                      nanTouPressed = false;
                                      yunLinPressed = false;

                                      huaLienPressed = false;
                                      taiDongPressed = false;
                                      kinMenPressed = false;
                                      lianJiangPressed = false;
                                    }
                                  });
                                },
                                child: Container(
                                  padding: EdgeInsets.only(left: 10, right: 10),
                                  decoration: newTaipeiPressed
                                      ? BoxDecoration(
                                          color: Color(0xFF444444),
                                          borderRadius: BorderRadius.all(
                                            Radius.circular(50),
                                          ))
                                      : BoxDecoration(),
                                  child: Row(
                                    children: [
                                      Container(
                                        height: 20,
                                        width: 14,
                                        margin: EdgeInsets.only(right: 3),
                                        decoration: newTaipeiPressed
                                            ? BoxDecoration(
                                                image: DecorationImage(
                                                  image: AssetImage(
                                                      "assets/base_widgets/icon_personal_file_coordinate.png"),
                                                  fit: BoxFit.fitWidth,
                                                ),
                                              )
                                            : BoxDecoration(),
                                      ),
                                      Container(
                                        padding: EdgeInsets.only(
                                            top: 11, bottom: 11),
                                        child: Text(
                                          "新北市",
                                          style: newTaipeiPressed
                                              ? TextStyle(
                                                  color: Color(0xFFE6CFA1),
                                                  fontSize: 14)
                                              : TextStyle(
                                                  color: Color(0xFFDDDDDD),
                                                  fontSize: 14),
                                        ),
                                      ),
                                    ],
                                  ),
                                ),
                              ),
                              //基隆市
                              GestureDetector(
                                onTap: () {
                                  // Navigator.pop(context, "台北市");
                                  setState(() {
                                    keeLungPressed = !keeLungPressed;
                                    if (keeLungPressed) {
                                      taiPeiPressed = false;
                                      newTaipeiPressed = false;
                                      yiLanPressed = false;

                                      taoYuanPressed = false;
                                      xinZuPressed = false;
                                      jiaMeiPressed = false;
                                      taiNanPressed = false;

                                      taiChungPressed = false;
                                      pingTungPressed = false;
                                      penHuPressed = false;
                                      miaoLiPressed = false;

                                      taiZhongPressed = false;
                                      changHuaPressed = false;
                                      nanTouPressed = false;
                                      yunLinPressed = false;

                                      huaLienPressed = false;
                                      taiDongPressed = false;
                                      kinMenPressed = false;
                                      lianJiangPressed = false;
                                    }
                                  });
                                },
                                child: Container(
                                  padding: EdgeInsets.only(left: 10, right: 10),
                                  decoration: keeLungPressed
                                      ? BoxDecoration(
                                          color: Color(0xFF444444),
                                          borderRadius: BorderRadius.all(
                                            Radius.circular(50),
                                          ))
                                      : BoxDecoration(),
                                  child: Row(
                                    children: [
                                      Container(
                                        height: 20,
                                        width: 14,
                                        margin: EdgeInsets.only(right: 3),
                                        decoration: keeLungPressed
                                            ? BoxDecoration(
                                                image: DecorationImage(
                                                  image: AssetImage(
                                                      "assets/base_widgets/icon_personal_file_coordinate.png"),
                                                  fit: BoxFit.fitWidth,
                                                ),
                                              )
                                            : BoxDecoration(),
                                      ),
                                      Container(
                                        padding: EdgeInsets.only(
                                            top: 11, bottom: 11),
                                        child: Text(
                                          "基隆市",
                                          style: keeLungPressed
                                              ? TextStyle(
                                                  color: Color(0xFFE6CFA1),
                                                  fontSize: 14)
                                              : TextStyle(
                                                  color: Color(0xFFDDDDDD),
                                                  fontSize: 14),
                                        ),
                                      ),
                                    ],
                                  ),
                                ),
                              ),
                              //依蘭縣
                              GestureDetector(
                                onTap: () {
                                  // Navigator.pop(context, "台北市");
                                  setState(() {
                                    yiLanPressed = !yiLanPressed;
                                    if (yiLanPressed) {
                                      taiPeiPressed = false;
                                      keeLungPressed = false;
                                      newTaipeiPressed = false;

                                      taoYuanPressed = false;
                                      xinZuPressed = false;
                                      jiaMeiPressed = false;
                                      taiNanPressed = false;

                                      taiChungPressed = false;
                                      pingTungPressed = false;
                                      penHuPressed = false;
                                      miaoLiPressed = false;

                                      taiZhongPressed = false;
                                      changHuaPressed = false;
                                      nanTouPressed = false;
                                      yunLinPressed = false;

                                      huaLienPressed = false;
                                      taiDongPressed = false;
                                      kinMenPressed = false;
                                      lianJiangPressed = false;
                                    }
                                  });
                                },
                                child: Container(
                                  padding: EdgeInsets.only(left: 10, right: 10),
                                  decoration: yiLanPressed
                                      ? BoxDecoration(
                                          color: Color(0xFF444444),
                                          borderRadius: BorderRadius.all(
                                            Radius.circular(50),
                                          ))
                                      : BoxDecoration(),
                                  child: Row(
                                    children: [
                                      Container(
                                        height: 20,
                                        width: 14,
                                        margin: EdgeInsets.only(right: 3),
                                        decoration: yiLanPressed
                                            ? BoxDecoration(
                                                image: DecorationImage(
                                                  image: AssetImage(
                                                      "assets/base_widgets/icon_personal_file_coordinate.png"),
                                                  fit: BoxFit.fitWidth,
                                                ),
                                              )
                                            : BoxDecoration(),
                                      ),
                                      GestureDetector(
                                        child: Container(
                                          padding: EdgeInsets.only(
                                              top: 11, bottom: 11),
                                          child: Text(
                                            "依蘭縣",
                                            style: yiLanPressed
                                                ? TextStyle(
                                                    color: Color(0xFFE6CFA1),
                                                    fontSize: 14)
                                                : TextStyle(
                                                    color: Color(0xFFDDDDDD),
                                                    fontSize: 14),
                                          ),
                                        ),
                                      ),
                                    ],
                                  ),
                                ),
                              ),
                            ],
                          ),
                          Row(
                            mainAxisAlignment: MainAxisAlignment.spaceEvenly,
                            children: [
                              //桃源縣
                              GestureDetector(
                                onTap: () {
                                  // Navigator.pop(context, "台北市");
                                  setState(() {
                                    taoYuanPressed = !taoYuanPressed;
                                    if (taoYuanPressed) {
                                      taiPeiPressed = false;
                                      keeLungPressed = false;
                                      yiLanPressed = false;

                                      newTaipeiPressed = false;
                                      xinZuPressed = false;
                                      jiaMeiPressed = false;
                                      taiNanPressed = false;

                                      taiChungPressed = false;
                                      pingTungPressed = false;
                                      penHuPressed = false;
                                      miaoLiPressed = false;

                                      taiZhongPressed = false;
                                      changHuaPressed = false;
                                      nanTouPressed = false;
                                      yunLinPressed = false;

                                      huaLienPressed = false;
                                      taiDongPressed = false;
                                      kinMenPressed = false;
                                      lianJiangPressed = false;
                                    }
                                  });
                                },
                                child: Container(
                                  padding: EdgeInsets.only(left: 10, right: 10),
                                  decoration: taoYuanPressed
                                      ? BoxDecoration(
                                          color: Color(0xFF444444),
                                          borderRadius: BorderRadius.all(
                                            Radius.circular(50),
                                          ))
                                      : BoxDecoration(),
                                  child: Row(
                                    children: [
                                      Container(
                                        height: 20,
                                        width: 14,
                                        margin: EdgeInsets.only(right: 3),
                                        decoration: taoYuanPressed
                                            ? BoxDecoration(
                                                image: DecorationImage(
                                                  image: AssetImage(
                                                      "assets/base_widgets/icon_personal_file_coordinate.png"),
                                                  fit: BoxFit.fitWidth,
                                                ),
                                              )
                                            : BoxDecoration(),
                                      ),
                                      Container(
                                        padding: EdgeInsets.only(
                                            top: 11, bottom: 11),
                                        child: Text(
                                          "桃源縣",
                                          style: taoYuanPressed
                                              ? TextStyle(
                                                  color: Color(0xFFE6CFA1),
                                                  fontSize: 14)
                                              : TextStyle(
                                                  color: Color(0xFFDDDDDD),
                                                  fontSize: 14),
                                        ),
                                      ),
                                    ],
                                  ),
                                ),
                              ),
                              //新竹縣
                              GestureDetector(
                                onTap: () {
                                  // Navigator.pop(context, "台北市");
                                  setState(() {
                                    xinZuPressed = !xinZuPressed;
                                    if (xinZuPressed) {
                                      taiPeiPressed = false;
                                      keeLungPressed = false;
                                      yiLanPressed = false;

                                      taoYuanPressed = false;
                                      newTaipeiPressed = false;
                                      jiaMeiPressed = false;
                                      taiNanPressed = false;

                                      taiChungPressed = false;
                                      pingTungPressed = false;
                                      penHuPressed = false;
                                      miaoLiPressed = false;

                                      taiZhongPressed = false;
                                      changHuaPressed = false;
                                      nanTouPressed = false;
                                      yunLinPressed = false;

                                      huaLienPressed = false;
                                      taiDongPressed = false;
                                      kinMenPressed = false;
                                      lianJiangPressed = false;
                                    }
                                  });
                                },
                                child: Container(
                                  padding: EdgeInsets.only(left: 10, right: 10),
                                  decoration: xinZuPressed
                                      ? BoxDecoration(
                                          color: Color(0xFF444444),
                                          borderRadius: BorderRadius.all(
                                            Radius.circular(50),
                                          ))
                                      : BoxDecoration(),
                                  child: Row(
                                    children: [
                                      Container(
                                        height: 20,
                                        width: 14,
                                        margin: EdgeInsets.only(right: 3),
                                        decoration: xinZuPressed
                                            ? BoxDecoration(
                                                image: DecorationImage(
                                                  image: AssetImage(
                                                      "assets/base_widgets/icon_personal_file_coordinate.png"),
                                                  fit: BoxFit.fitWidth,
                                                ),
                                              )
                                            : BoxDecoration(),
                                      ),
                                      Container(
                                        padding: EdgeInsets.only(
                                            top: 11, bottom: 11),
                                        child: Text(
                                          "新竹縣",
                                          style: xinZuPressed
                                              ? TextStyle(
                                                  color: Color(0xFFE6CFA1),
                                                  fontSize: 14)
                                              : TextStyle(
                                                  color: Color(0xFFDDDDDD),
                                                  fontSize: 14),
                                        ),
                                      ),
                                    ],
                                  ),
                                ),
                              ),
                              //嘉美市
                              GestureDetector(
                                onTap: () {
                                  // Navigator.pop(context, "台北市");
                                  setState(() {
                                    jiaMeiPressed = !jiaMeiPressed;
                                    if (jiaMeiPressed) {
                                      taiPeiPressed = false;
                                      keeLungPressed = false;
                                      yiLanPressed = false;

                                      taoYuanPressed = false;
                                      xinZuPressed = false;
                                      newTaipeiPressed = false;
                                      taiNanPressed = false;

                                      taiChungPressed = false;
                                      pingTungPressed = false;
                                      penHuPressed = false;
                                      miaoLiPressed = false;

                                      taiZhongPressed = false;
                                      changHuaPressed = false;
                                      nanTouPressed = false;
                                      yunLinPressed = false;

                                      huaLienPressed = false;
                                      taiDongPressed = false;
                                      kinMenPressed = false;
                                      lianJiangPressed = false;
                                    }
                                  });
                                },
                                child: Container(
                                  padding: EdgeInsets.only(left: 10, right: 10),
                                  decoration: jiaMeiPressed
                                      ? BoxDecoration(
                                          color: Color(0xFF444444),
                                          borderRadius: BorderRadius.all(
                                            Radius.circular(50),
                                          ))
                                      : BoxDecoration(),
                                  child: Row(
                                    children: [
                                      Container(
                                        height: 20,
                                        width: 14,
                                        margin: EdgeInsets.only(right: 3),
                                        decoration: jiaMeiPressed
                                            ? BoxDecoration(
                                                image: DecorationImage(
                                                  image: AssetImage(
                                                      "assets/base_widgets/icon_personal_file_coordinate.png"),
                                                  fit: BoxFit.fitWidth,
                                                ),
                                              )
                                            : BoxDecoration(),
                                      ),
                                      Container(
                                        padding: EdgeInsets.only(
                                            top: 11, bottom: 11),
                                        child: Text(
                                          "嘉美市",
                                          style: jiaMeiPressed
                                              ? TextStyle(
                                                  color: Color(0xFFE6CFA1),
                                                  fontSize: 14)
                                              : TextStyle(
                                                  color: Color(0xFFDDDDDD),
                                                  fontSize: 14),
                                        ),
                                      ),
                                    ],
                                  ),
                                ),
                              ),
                              //台南市
                              GestureDetector(
                                onTap: () {
                                  // Navigator.pop(context, "台北市");
                                  setState(() {
                                    taiNanPressed = !taiNanPressed;
                                    if (taiNanPressed) {
                                      taiPeiPressed = false;
                                      keeLungPressed = false;
                                      yiLanPressed = false;

                                      taoYuanPressed = false;
                                      xinZuPressed = false;
                                      jiaMeiPressed = false;
                                      newTaipeiPressed = false;

                                      taiChungPressed = false;
                                      pingTungPressed = false;
                                      penHuPressed = false;
                                      miaoLiPressed = false;

                                      taiZhongPressed = false;
                                      changHuaPressed = false;
                                      nanTouPressed = false;
                                      yunLinPressed = false;

                                      huaLienPressed = false;
                                      taiDongPressed = false;
                                      kinMenPressed = false;
                                      lianJiangPressed = false;
                                    }
                                  });
                                },
                                child: Container(
                                  padding: EdgeInsets.only(left: 10, right: 10),
                                  decoration: taiNanPressed
                                      ? BoxDecoration(
                                          color: Color(0xFF444444),
                                          borderRadius: BorderRadius.all(
                                            Radius.circular(50),
                                          ))
                                      : BoxDecoration(),
                                  child: Row(
                                    children: [
                                      Container(
                                        height: 20,
                                        width: 14,
                                        margin: EdgeInsets.only(right: 3),
                                        decoration: taiNanPressed
                                            ? BoxDecoration(
                                                image: DecorationImage(
                                                  image: AssetImage(
                                                      "assets/base_widgets/icon_personal_file_coordinate.png"),
                                                  fit: BoxFit.fitWidth,
                                                ),
                                              )
                                            : BoxDecoration(),
                                      ),
                                      GestureDetector(
                                        child: Container(
                                          padding: EdgeInsets.only(
                                              top: 11, bottom: 11),
                                          child: Text(
                                            "台南市",
                                            style: taiNanPressed
                                                ? TextStyle(
                                                    color: Color(0xFFE6CFA1),
                                                    fontSize: 14)
                                                : TextStyle(
                                                    color: Color(0xFFDDDDDD),
                                                    fontSize: 14),
                                          ),
                                        ),
                                      ),
                                    ],
                                  ),
                                ),
                              ),
                            ],
                          ),
                          Row(
                            mainAxisAlignment: MainAxisAlignment.spaceEvenly,
                            children: [
                              //臺中市
                              GestureDetector(
                                onTap: () {
                                  // Navigator.pop(context, "台北市");
                                  setState(() {
                                    taiChungPressed = !taiChungPressed;
                                    if (taiChungPressed) {
                                      taiPeiPressed = false;
                                      keeLungPressed = false;
                                      yiLanPressed = false;

                                      taoYuanPressed = false;
                                      xinZuPressed = false;
                                      jiaMeiPressed = false;
                                      taiNanPressed = false;

                                      newTaipeiPressed = false;
                                      pingTungPressed = false;
                                      penHuPressed = false;
                                      miaoLiPressed = false;

                                      taiZhongPressed = false;
                                      changHuaPressed = false;
                                      nanTouPressed = false;
                                      yunLinPressed = false;

                                      huaLienPressed = false;
                                      taiDongPressed = false;
                                      kinMenPressed = false;
                                      lianJiangPressed = false;
                                    }
                                  });
                                },
                                child: Container(
                                  padding: EdgeInsets.only(left: 10, right: 10),
                                  decoration: taiChungPressed
                                      ? BoxDecoration(
                                          color: Color(0xFF444444),
                                          borderRadius: BorderRadius.all(
                                            Radius.circular(50),
                                          ))
                                      : BoxDecoration(),
                                  child: Row(
                                    children: [
                                      Container(
                                        height: 20,
                                        width: 14,
                                        margin: EdgeInsets.only(right: 3),
                                        decoration: taiChungPressed
                                            ? BoxDecoration(
                                                image: DecorationImage(
                                                  image: AssetImage(
                                                      "assets/base_widgets/icon_personal_file_coordinate.png"),
                                                  fit: BoxFit.fitWidth,
                                                ),
                                              )
                                            : BoxDecoration(),
                                      ),
                                      Container(
                                        padding: EdgeInsets.only(
                                            top: 11, bottom: 11),
                                        child: Text(
                                          "臺中市",
                                          style: taiChungPressed
                                              ? TextStyle(
                                                  color: Color(0xFFE6CFA1),
                                                  fontSize: 14)
                                              : TextStyle(
                                                  color: Color(0xFFDDDDDD),
                                                  fontSize: 14),
                                        ),
                                      ),
                                    ],
                                  ),
                                ),
                              ),
                              //屏東縣
                              GestureDetector(
                                onTap: () {
                                  // Navigator.pop(context, "台北市");
                                  setState(() {
                                    pingTungPressed = !pingTungPressed;
                                    if (pingTungPressed) {
                                      taiPeiPressed = false;
                                      keeLungPressed = false;
                                      yiLanPressed = false;

                                      taoYuanPressed = false;
                                      xinZuPressed = false;
                                      jiaMeiPressed = false;
                                      taiNanPressed = false;

                                      taiChungPressed = false;
                                      newTaipeiPressed = false;
                                      penHuPressed = false;
                                      miaoLiPressed = false;

                                      taiZhongPressed = false;
                                      changHuaPressed = false;
                                      nanTouPressed = false;
                                      yunLinPressed = false;

                                      huaLienPressed = false;
                                      taiDongPressed = false;
                                      kinMenPressed = false;
                                      lianJiangPressed = false;
                                    }
                                  });
                                },
                                child: Container(
                                  padding: EdgeInsets.only(left: 10, right: 10),
                                  decoration: pingTungPressed
                                      ? BoxDecoration(
                                          color: Color(0xFF444444),
                                          borderRadius: BorderRadius.all(
                                            Radius.circular(50),
                                          ))
                                      : BoxDecoration(),
                                  child: Row(
                                    children: [
                                      Container(
                                        height: 20,
                                        width: 14,
                                        margin: EdgeInsets.only(right: 3),
                                        decoration: pingTungPressed
                                            ? BoxDecoration(
                                                image: DecorationImage(
                                                  image: AssetImage(
                                                      "assets/base_widgets/icon_personal_file_coordinate.png"),
                                                  fit: BoxFit.fitWidth,
                                                ),
                                              )
                                            : BoxDecoration(),
                                      ),
                                      Container(
                                        padding: EdgeInsets.only(
                                            top: 11, bottom: 11),
                                        child: Text(
                                          "屏東縣",
                                          style: pingTungPressed
                                              ? TextStyle(
                                                  color: Color(0xFFE6CFA1),
                                                  fontSize: 14)
                                              : TextStyle(
                                                  color: Color(0xFFDDDDDD),
                                                  fontSize: 14),
                                        ),
                                      ),
                                    ],
                                  ),
                                ),
                              ),
                              //澎湖縣
                              GestureDetector(
                                onTap: () {
                                  // Navigator.pop(context, "台北市");
                                  setState(() {
                                    penHuPressed = !penHuPressed;
                                    if (penHuPressed) {
                                      taiPeiPressed = false;
                                      keeLungPressed = false;
                                      yiLanPressed = false;

                                      taoYuanPressed = false;
                                      xinZuPressed = false;
                                      jiaMeiPressed = false;
                                      taiNanPressed = false;

                                      taiChungPressed = false;
                                      pingTungPressed = false;
                                      newTaipeiPressed = false;
                                      miaoLiPressed = false;

                                      taiZhongPressed = false;
                                      changHuaPressed = false;
                                      nanTouPressed = false;
                                      yunLinPressed = false;

                                      huaLienPressed = false;
                                      taiDongPressed = false;
                                      kinMenPressed = false;
                                      lianJiangPressed = false;
                                    }
                                  });
                                },
                                child: Container(
                                  padding: EdgeInsets.only(left: 10, right: 10),
                                  decoration: penHuPressed
                                      ? BoxDecoration(
                                          color: Color(0xFF444444),
                                          borderRadius: BorderRadius.all(
                                            Radius.circular(50),
                                          ))
                                      : BoxDecoration(),
                                  child: Row(
                                    children: [
                                      Container(
                                        height: 20,
                                        width: 14,
                                        margin: EdgeInsets.only(right: 3),
                                        decoration: penHuPressed
                                            ? BoxDecoration(
                                                image: DecorationImage(
                                                  image: AssetImage(
                                                      "assets/base_widgets/icon_personal_file_coordinate.png"),
                                                  fit: BoxFit.fitWidth,
                                                ),
                                              )
                                            : BoxDecoration(),
                                      ),
                                      Container(
                                        padding: EdgeInsets.only(
                                            top: 11, bottom: 11),
                                        child: Text(
                                          "澎湖縣",
                                          style: penHuPressed
                                              ? TextStyle(
                                                  color: Color(0xFFE6CFA1),
                                                  fontSize: 14)
                                              : TextStyle(
                                                  color: Color(0xFFDDDDDD),
                                                  fontSize: 14),
                                        ),
                                      ),
                                    ],
                                  ),
                                ),
                              ),
                              //苗栗縣
                              GestureDetector(
                                onTap: () {
                                  // Navigator.pop(context, "台北市");
                                  setState(() {
                                    miaoLiPressed = !miaoLiPressed;
                                    if (miaoLiPressed) {
                                      taiPeiPressed = false;
                                      keeLungPressed = false;
                                      yiLanPressed = false;

                                      taoYuanPressed = false;
                                      xinZuPressed = false;
                                      jiaMeiPressed = false;
                                      taiNanPressed = false;

                                      taiChungPressed = false;
                                      pingTungPressed = false;
                                      penHuPressed = false;
                                      newTaipeiPressed = false;

                                      taiZhongPressed = false;
                                      changHuaPressed = false;
                                      nanTouPressed = false;
                                      yunLinPressed = false;

                                      huaLienPressed = false;
                                      taiDongPressed = false;
                                      kinMenPressed = false;
                                      lianJiangPressed = false;
                                    }
                                  });
                                },
                                child: Container(
                                  padding: EdgeInsets.only(left: 10, right: 10),
                                  decoration: miaoLiPressed
                                      ? BoxDecoration(
                                          color: Color(0xFF444444),
                                          borderRadius: BorderRadius.all(
                                            Radius.circular(50),
                                          ))
                                      : BoxDecoration(),
                                  child: Row(
                                    children: [
                                      Container(
                                        height: 20,
                                        width: 14,
                                        margin: EdgeInsets.only(right: 3),
                                        decoration: miaoLiPressed
                                            ? BoxDecoration(
                                                image: DecorationImage(
                                                  image: AssetImage(
                                                      "assets/base_widgets/icon_personal_file_coordinate.png"),
                                                  fit: BoxFit.fitWidth,
                                                ),
                                              )
                                            : BoxDecoration(),
                                      ),
                                      GestureDetector(
                                        child: Container(
                                          padding: EdgeInsets.only(
                                              top: 11, bottom: 11),
                                          child: Text(
                                            "苗栗縣",
                                            style: miaoLiPressed
                                                ? TextStyle(
                                                    color: Color(0xFFE6CFA1),
                                                    fontSize: 14)
                                                : TextStyle(
                                                    color: Color(0xFFDDDDDD),
                                                    fontSize: 14),
                                          ),
                                        ),
                                      ),
                                    ],
                                  ),
                                ),
                              ),
                            ],
                          ),
                          Row(
                            mainAxisAlignment: MainAxisAlignment.spaceEvenly,
                            children: [
                              //台中市
                              GestureDetector(
                                onTap: () {
                                  // Navigator.pop(context, "台北市");
                                  setState(() {
                                    taiZhongPressed = !taiZhongPressed;
                                    if (taiZhongPressed) {
                                      taiPeiPressed = false;
                                      keeLungPressed = false;
                                      yiLanPressed = false;

                                      taoYuanPressed = false;
                                      xinZuPressed = false;
                                      jiaMeiPressed = false;
                                      taiNanPressed = false;

                                      taiChungPressed = false;
                                      pingTungPressed = false;
                                      penHuPressed = false;
                                      miaoLiPressed = false;

                                      newTaipeiPressed = false;
                                      changHuaPressed = false;
                                      nanTouPressed = false;
                                      yunLinPressed = false;

                                      huaLienPressed = false;
                                      taiDongPressed = false;
                                      kinMenPressed = false;
                                      lianJiangPressed = false;
                                    }
                                  });
                                },
                                child: Container(
                                  padding: EdgeInsets.only(left: 10, right: 10),
                                  decoration: taiZhongPressed
                                      ? BoxDecoration(
                                          color: Color(0xFF444444),
                                          borderRadius: BorderRadius.all(
                                            Radius.circular(50),
                                          ))
                                      : BoxDecoration(),
                                  child: Row(
                                    children: [
                                      Container(
                                        height: 20,
                                        width: 14,
                                        margin: EdgeInsets.only(right: 3),
                                        decoration: taiZhongPressed
                                            ? BoxDecoration(
                                                image: DecorationImage(
                                                  image: AssetImage(
                                                      "assets/base_widgets/icon_personal_file_coordinate.png"),
                                                  fit: BoxFit.fitWidth,
                                                ),
                                              )
                                            : BoxDecoration(),
                                      ),
                                      Container(
                                        padding: EdgeInsets.only(
                                            top: 11, bottom: 11),
                                        child: Text(
                                          "台中市",
                                          style: taiZhongPressed
                                              ? TextStyle(
                                                  color: Color(0xFFE6CFA1),
                                                  fontSize: 14)
                                              : TextStyle(
                                                  color: Color(0xFFDDDDDD),
                                                  fontSize: 14),
                                        ),
                                      ),
                                    ],
                                  ),
                                ),
                              ),
                              //彰化縣
                              GestureDetector(
                                onTap: () {
                                  // Navigator.pop(context, "台北市");
                                  setState(() {
                                    changHuaPressed = !changHuaPressed;
                                    if (changHuaPressed) {
                                      taiPeiPressed = false;
                                      keeLungPressed = false;
                                      yiLanPressed = false;

                                      taoYuanPressed = false;
                                      xinZuPressed = false;
                                      jiaMeiPressed = false;
                                      taiNanPressed = false;

                                      taiChungPressed = false;
                                      pingTungPressed = false;
                                      penHuPressed = false;
                                      miaoLiPressed = false;

                                      taiZhongPressed = false;
                                      newTaipeiPressed = false;
                                      nanTouPressed = false;
                                      yunLinPressed = false;

                                      huaLienPressed = false;
                                      taiDongPressed = false;
                                      kinMenPressed = false;
                                      lianJiangPressed = false;
                                    }
                                  });
                                },
                                child: Container(
                                  padding: EdgeInsets.only(left: 10, right: 10),
                                  decoration: changHuaPressed
                                      ? BoxDecoration(
                                          color: Color(0xFF444444),
                                          borderRadius: BorderRadius.all(
                                            Radius.circular(50),
                                          ))
                                      : BoxDecoration(),
                                  child: Row(
                                    children: [
                                      Container(
                                        height: 20,
                                        width: 14,
                                        margin: EdgeInsets.only(right: 3),
                                        decoration: changHuaPressed
                                            ? BoxDecoration(
                                                image: DecorationImage(
                                                  image: AssetImage(
                                                      "assets/base_widgets/icon_personal_file_coordinate.png"),
                                                  fit: BoxFit.fitWidth,
                                                ),
                                              )
                                            : BoxDecoration(),
                                      ),
                                      Container(
                                        padding: EdgeInsets.only(
                                            top: 11, bottom: 11),
                                        child: Text(
                                          "彰化縣",
                                          style: changHuaPressed
                                              ? TextStyle(
                                                  color: Color(0xFFE6CFA1),
                                                  fontSize: 14)
                                              : TextStyle(
                                                  color: Color(0xFFDDDDDD),
                                                  fontSize: 14),
                                        ),
                                      ),
                                    ],
                                  ),
                                ),
                              ),
                              //南投縣
                              GestureDetector(
                                onTap: () {
                                  // Navigator.pop(context, "台北市");
                                  setState(() {
                                    nanTouPressed = !nanTouPressed;
                                    if (nanTouPressed) {
                                      taiPeiPressed = false;
                                      keeLungPressed = false;
                                      yiLanPressed = false;

                                      taoYuanPressed = false;
                                      xinZuPressed = false;
                                      jiaMeiPressed = false;
                                      taiNanPressed = false;

                                      taiChungPressed = false;
                                      pingTungPressed = false;
                                      penHuPressed = false;
                                      miaoLiPressed = false;

                                      taiZhongPressed = false;
                                      changHuaPressed = false;
                                      newTaipeiPressed = false;
                                      yunLinPressed = false;

                                      huaLienPressed = false;
                                      taiDongPressed = false;
                                      kinMenPressed = false;
                                      lianJiangPressed = false;
                                    }
                                  });
                                },
                                child: Container(
                                  padding: EdgeInsets.only(left: 10, right: 10),
                                  decoration: nanTouPressed
                                      ? BoxDecoration(
                                          color: Color(0xFF444444),
                                          borderRadius: BorderRadius.all(
                                            Radius.circular(50),
                                          ))
                                      : BoxDecoration(),
                                  child: Row(
                                    children: [
                                      Container(
                                        height: 20,
                                        width: 14,
                                        margin: EdgeInsets.only(right: 3),
                                        decoration: nanTouPressed
                                            ? BoxDecoration(
                                                image: DecorationImage(
                                                  image: AssetImage(
                                                      "assets/base_widgets/icon_personal_file_coordinate.png"),
                                                  fit: BoxFit.fitWidth,
                                                ),
                                              )
                                            : BoxDecoration(),
                                      ),
                                      Container(
                                        padding: EdgeInsets.only(
                                            top: 11, bottom: 11),
                                        child: Text(
                                          "南投縣",
                                          style: nanTouPressed
                                              ? TextStyle(
                                                  color: Color(0xFFE6CFA1),
                                                  fontSize: 14)
                                              : TextStyle(
                                                  color: Color(0xFFDDDDDD),
                                                  fontSize: 14),
                                        ),
                                      ),
                                    ],
                                  ),
                                ),
                              ),
                              //雲林縣
                              GestureDetector(
                                onTap: () {
                                  // Navigator.pop(context, "台北市");
                                  setState(() {
                                    yunLinPressed = !yunLinPressed;
                                    if (yunLinPressed) {
                                      taiPeiPressed = false;
                                      keeLungPressed = false;
                                      yiLanPressed = false;

                                      taoYuanPressed = false;
                                      xinZuPressed = false;
                                      jiaMeiPressed = false;
                                      taiNanPressed = false;

                                      taiChungPressed = false;
                                      pingTungPressed = false;
                                      penHuPressed = false;
                                      miaoLiPressed = false;

                                      taiZhongPressed = false;
                                      changHuaPressed = false;
                                      nanTouPressed = false;
                                      newTaipeiPressed = false;

                                      huaLienPressed = false;
                                      taiDongPressed = false;
                                      kinMenPressed = false;
                                      lianJiangPressed = false;
                                    }
                                  });
                                },
                                child: Container(
                                  padding: EdgeInsets.only(left: 10, right: 10),
                                  decoration: yunLinPressed
                                      ? BoxDecoration(
                                          color: Color(0xFF444444),
                                          borderRadius: BorderRadius.all(
                                            Radius.circular(50),
                                          ))
                                      : BoxDecoration(),
                                  child: Row(
                                    children: [
                                      Container(
                                        height: 20,
                                        width: 14,
                                        margin: EdgeInsets.only(right: 3),
                                        decoration: yunLinPressed
                                            ? BoxDecoration(
                                                image: DecorationImage(
                                                  image: AssetImage(
                                                      "assets/base_widgets/icon_personal_file_coordinate.png"),
                                                  fit: BoxFit.fitWidth,
                                                ),
                                              )
                                            : BoxDecoration(),
                                      ),
                                      GestureDetector(
                                        child: Container(
                                          padding: EdgeInsets.only(
                                              top: 11, bottom: 11),
                                          child: Text(
                                            "雲林縣",
                                            style: yunLinPressed
                                                ? TextStyle(
                                                    color: Color(0xFFE6CFA1),
                                                    fontSize: 14)
                                                : TextStyle(
                                                    color: Color(0xFFDDDDDD),
                                                    fontSize: 14),
                                          ),
                                        ),
                                      ),
                                    ],
                                  ),
                                ),
                              ),
                            ],
                          ),
                          Row(
                            mainAxisAlignment: MainAxisAlignment.spaceEvenly,
                            children: [
                              //花蓮縣
                              GestureDetector(
                                onTap: () {
                                  // Navigator.pop(context, "台北市");
                                  setState(() {
                                    huaLienPressed = !huaLienPressed;
                                    if (huaLienPressed) {
                                      taiPeiPressed = false;
                                      keeLungPressed = false;
                                      yiLanPressed = false;

                                      taoYuanPressed = false;
                                      xinZuPressed = false;
                                      jiaMeiPressed = false;
                                      taiNanPressed = false;

                                      taiChungPressed = false;
                                      pingTungPressed = false;
                                      penHuPressed = false;
                                      miaoLiPressed = false;

                                      taiZhongPressed = false;
                                      changHuaPressed = false;
                                      nanTouPressed = false;
                                      yunLinPressed = false;

                                      newTaipeiPressed = false;
                                      taiDongPressed = false;
                                      kinMenPressed = false;
                                      lianJiangPressed = false;
                                    }
                                  });
                                },
                                child: Container(
                                  padding: EdgeInsets.only(left: 10, right: 10),
                                  decoration: huaLienPressed
                                      ? BoxDecoration(
                                          color: Color(0xFF444444),
                                          borderRadius: BorderRadius.all(
                                            Radius.circular(50),
                                          ))
                                      : BoxDecoration(),
                                  child: Row(
                                    children: [
                                      Container(
                                        height: 20,
                                        width: 14,
                                        margin: EdgeInsets.only(right: 3),
                                        decoration: huaLienPressed
                                            ? BoxDecoration(
                                                image: DecorationImage(
                                                  image: AssetImage(
                                                      "assets/base_widgets/icon_personal_file_coordinate.png"),
                                                  fit: BoxFit.fitWidth,
                                                ),
                                              )
                                            : BoxDecoration(),
                                      ),
                                      Container(
                                        padding: EdgeInsets.only(
                                            top: 11, bottom: 11),
                                        child: Text(
                                          "花蓮縣",
                                          style: huaLienPressed
                                              ? TextStyle(
                                                  color: Color(0xFFE6CFA1),
                                                  fontSize: 14)
                                              : TextStyle(
                                                  color: Color(0xFFDDDDDD),
                                                  fontSize: 14),
                                        ),
                                      ),
                                    ],
                                  ),
                                ),
                              ),
                              //台東縣
                              GestureDetector(
                                onTap: () {
                                  // Navigator.pop(context, "台北市");
                                  setState(() {
                                    taiDongPressed = !taiDongPressed;
                                    if (taiDongPressed) {
                                      taiPeiPressed = false;
                                      keeLungPressed = false;
                                      yiLanPressed = false;

                                      taoYuanPressed = false;
                                      xinZuPressed = false;
                                      jiaMeiPressed = false;
                                      taiNanPressed = false;

                                      taiChungPressed = false;
                                      pingTungPressed = false;
                                      penHuPressed = false;
                                      miaoLiPressed = false;

                                      taiZhongPressed = false;
                                      changHuaPressed = false;
                                      nanTouPressed = false;
                                      yunLinPressed = false;

                                      huaLienPressed = false;
                                      newTaipeiPressed = false;
                                      kinMenPressed = false;
                                      lianJiangPressed = false;
                                    }
                                  });
                                },
                                child: Container(
                                  padding: EdgeInsets.only(left: 10, right: 10),
                                  decoration: taiDongPressed
                                      ? BoxDecoration(
                                          color: Color(0xFF444444),
                                          borderRadius: BorderRadius.all(
                                            Radius.circular(50),
                                          ))
                                      : BoxDecoration(),
                                  child: Row(
                                    children: [
                                      Container(
                                        height: 20,
                                        width: 14,
                                        margin: EdgeInsets.only(right: 3),
                                        decoration: taiDongPressed
                                            ? BoxDecoration(
                                                image: DecorationImage(
                                                  image: AssetImage(
                                                      "assets/base_widgets/icon_personal_file_coordinate.png"),
                                                  fit: BoxFit.fitWidth,
                                                ),
                                              )
                                            : BoxDecoration(),
                                      ),
                                      Container(
                                        padding: EdgeInsets.only(
                                            top: 11, bottom: 11),
                                        child: Text(
                                          "台東縣",
                                          style: taiDongPressed
                                              ? TextStyle(
                                                  color: Color(0xFFE6CFA1),
                                                  fontSize: 14)
                                              : TextStyle(
                                                  color: Color(0xFFDDDDDD),
                                                  fontSize: 14),
                                        ),
                                      ),
                                    ],
                                  ),
                                ),
                              ),
                              //金門縣
                              GestureDetector(
                                onTap: () {
                                  // Navigator.pop(context, "台北市");
                                  setState(() {
                                    kinMenPressed = !kinMenPressed;
                                    if (kinMenPressed) {
                                      taiPeiPressed = false;
                                      keeLungPressed = false;
                                      yiLanPressed = false;

                                      taoYuanPressed = false;
                                      xinZuPressed = false;
                                      jiaMeiPressed = false;
                                      taiNanPressed = false;

                                      taiChungPressed = false;
                                      pingTungPressed = false;
                                      penHuPressed = false;
                                      miaoLiPressed = false;

                                      taiZhongPressed = false;
                                      changHuaPressed = false;
                                      nanTouPressed = false;
                                      yunLinPressed = false;

                                      huaLienPressed = false;
                                      taiDongPressed = false;
                                      newTaipeiPressed = false;
                                      lianJiangPressed = false;
                                    }
                                  });
                                },
                                child: Container(
                                  padding: EdgeInsets.only(left: 10, right: 10),
                                  decoration: kinMenPressed
                                      ? BoxDecoration(
                                          color: Color(0xFF444444),
                                          borderRadius: BorderRadius.all(
                                            Radius.circular(50),
                                          ))
                                      : BoxDecoration(),
                                  child: Row(
                                    children: [
                                      Container(
                                        height: 20,
                                        width: 14,
                                        margin: EdgeInsets.only(right: 3),
                                        decoration: kinMenPressed
                                            ? BoxDecoration(
                                                image: DecorationImage(
                                                  image: AssetImage(
                                                      "assets/base_widgets/icon_personal_file_coordinate.png"),
                                                  fit: BoxFit.fitWidth,
                                                ),
                                              )
                                            : BoxDecoration(),
                                      ),
                                      Container(
                                        padding: EdgeInsets.only(
                                            top: 11, bottom: 11),
                                        child: Text(
                                          "金門縣",
                                          style: kinMenPressed
                                              ? TextStyle(
                                                  color: Color(0xFFE6CFA1),
                                                  fontSize: 14)
                                              : TextStyle(
                                                  color: Color(0xFFDDDDDD),
                                                  fontSize: 14),
                                        ),
                                      ),
                                    ],
                                  ),
                                ),
                              ),
                              //連江縣
                              GestureDetector(
                                onTap: () {
                                  // Navigator.pop(context, "台北市");
                                  setState(() {
                                    lianJiangPressed = !lianJiangPressed;
                                    if (lianJiangPressed) {
                                      taiPeiPressed = false;
                                      keeLungPressed = false;
                                      yiLanPressed = false;

                                      taoYuanPressed = false;
                                      xinZuPressed = false;
                                      jiaMeiPressed = false;
                                      taiNanPressed = false;

                                      taiChungPressed = false;
                                      pingTungPressed = false;
                                      penHuPressed = false;
                                      miaoLiPressed = false;

                                      taiZhongPressed = false;
                                      changHuaPressed = false;
                                      nanTouPressed = false;
                                      yunLinPressed = false;

                                      huaLienPressed = false;
                                      taiDongPressed = false;
                                      kinMenPressed = false;
                                      newTaipeiPressed = false;
                                    }
                                  });
                                },
                                child: Container(
                                  padding: EdgeInsets.only(left: 10, right: 10),
                                  decoration: lianJiangPressed
                                      ? BoxDecoration(
                                          color: Color(0xFF444444),
                                          borderRadius: BorderRadius.all(
                                            Radius.circular(50),
                                          ))
                                      : BoxDecoration(),
                                  child: Row(
                                    children: [
                                      Container(
                                        height: 20,
                                        width: 14,
                                        margin: EdgeInsets.only(right: 3),
                                        decoration: lianJiangPressed
                                            ? BoxDecoration(
                                                image: DecorationImage(
                                                  image: AssetImage(
                                                      "assets/base_widgets/icon_personal_file_coordinate.png"),
                                                  fit: BoxFit.fitWidth,
                                                ),
                                              )
                                            : BoxDecoration(),
                                      ),
                                      GestureDetector(
                                        child: Container(
                                          padding: EdgeInsets.only(
                                              top: 11, bottom: 11),
                                          child: Text(
                                            "連江縣",
                                            style: lianJiangPressed
                                                ? TextStyle(
                                                    color: Color(0xFFE6CFA1),
                                                    fontSize: 14)
                                                : TextStyle(
                                                    color: Color(0xFFDDDDDD),
                                                    fontSize: 14),
                                          ),
                                        ),
                                      ),
                                    ],
                                  ),
                                ),
                              ),
                            ],
                          ),
                          //分割线
                          Container(
                            margin:
                                EdgeInsets.only(top: 15, left: 15, right: 15),
                            height: 1,
                            decoration: BoxDecoration(color: Color(0xFF444444)),
                          ),
                          Row(
                            children: [
                              Container(
                                margin: EdgeInsets.only(left: 15, top: 10,bottom: 10),
                                child: Text(
                                  "其他",
                                  style: TextStyle(
                                      color: Color(0xFFDDDDDD), fontSize: 19),
                                ),
                              ),
                            ],
                          )
                        ],
                      ),
                         Expanded(
                          flex: 1,
                          child: AzListView(
                            data: _cityList,
                            // topData: _hotCityList,
                            itemBuilder: (context, model) =>
                                _buildListItem(model,context),
                            // suspensionWidget: _buildSusWidget(_suspensionTag),
                            itemHeight: _itemHeight,
                            suspensionHeight: _suspensionHeight,
                            onSusTagChanged: _onSusTagChanged,
                            showIndexHint: true,
                          ),
                        ),
                    ],
                  ),
                ),
              ],
            )),
      ),
    );
  }
}

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
好的,下面是一个简单的登录界面示例,使用了 Flutter 的 Material Design 风格。 首先,在 `pubspec.yaml` 文件中添加 Material Design 库: ```yaml dependencies: flutter: sdk: flutter cupertino_icons: ^0.1.2 material_design_icons_flutter: ^3.6.95 ``` 然后,在 `lib/main.dart` 文件中编写代码: ```dart import 'package:flutter/material.dart'; import 'package:material_design_icons_flutter/material_design_icons_flutter.dart'; void main() => runApp(MyApp()); class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( title: 'Login Demo', theme: ThemeData( primarySwatch: Colors.blue, ), home: LoginPage(), ); } } class LoginPage extends StatefulWidget { @override _LoginPageState createState() => _LoginPageState(); } class _LoginPageState extends State<LoginPage> { final _formKey = GlobalKey<FormState>(); String _email; String _password; @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text('Login'), ), body: Center( child: Form( key: _formKey, child: Column( mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[ TextFormField( decoration: InputDecoration( labelText: 'Email', prefixIcon: Icon(MdiIcons.email), ), keyboardType: TextInputType.emailAddress, validator: (value) { if (value.isEmpty) { return 'Please enter your email'; } return null; }, onSaved: (value) { _email = value; }, ), TextFormField( decoration: InputDecoration( labelText: 'Password', prefixIcon: Icon(MdiIcons.lock), ), obscureText: true, validator: (value) { if (value.isEmpty) { return 'Please enter your password'; } return null; }, onSaved: (value) { _password = value; }, ), SizedBox( height: 24, ), RaisedButton( onPressed: () { if (_formKey.currentState.validate()) { _formKey.currentState.save(); // TODO: Perform login action } }, child: Text('Login'), ), ], ), ), ), ); } } ``` 这个示例中,我们使用了 `Form` 和 `TextFormField` 来创建表单,使用了 Material Design 风格的图标来增强用户体验。 在表单的提交按钮中,我们可以执行具体的登录操作。你可以根据自己的需求来实现这个逻辑。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值