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