Flutter实现仿京东地址选择组件,省市区三级级联选择器,数据为模拟数据,可根据真实接口数据改造,也可扩展成为省市区街道四级选择,
下载地址:https://download.csdn.net/dow...
效果图如下:
文章图片
主要实现代码如下:
// 省TabView
_provinceTabView() {
return ListView.builder(
itemBuilder: (BuildContext context, int index) {
return InkWell(
onTap: () => areaChange(0, index),
child: _nameBar(provinceList[index]['name'], provinceActive == index));
},
itemCount: provinceList.length);
}
// 市
_cityTabView() {
return ListView.builder(
itemBuilder: (BuildContext context, int index) {
return InkWell(
onTap: () => areaChange(1, index),
child: _nameBar(
provinceList[provinceActive]['city'][index]['name'], cityActive == index));
},
itemCount: provinceList[provinceActive]['city'].length);
}
// 区县
_areaTabView() {
return ListView.builder(
itemBuilder: (BuildContext context, int index) {
return InkWell(
onTap: () => areaChange(2, index),
child: _nameBar(
provinceList[provinceActive]['city'][cityActive]['area'][index]['name'],
areaActive == index));
},
itemCount: provinceList[provinceActive]['city'][cityActive]['area'].length);
【Flutter实现仿京东地址选择组件】}