当前位置:网站首页>Flutter implements the JD address selection component

Flutter implements the JD address selection component

2022-06-11 21:16:00 Yu Shun

Flutter Realize the imitation Jingdong address selection component , Provincial and urban three-level cascade selector , The data is analog data , It can be modified according to the real interface data , It can also be expanded into a four-level choice for streets in provinces and urban areas , The renderings are as follows :

The main implementation code is as follows :
// province 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);

}

// City
_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);

}

// District and county
_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);

}

原网站

版权声明
本文为[Yu Shun]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/03/202203011706547727.html