How can I iterate over an array of objects which belong to a key value - Flutter

后端 未结 3 961
-上瘾入骨i
-上瘾入骨i 2021-01-29 00:38

I have a list of data called anchors that has a link to a detailed screen. And each anchor has distribution centers which are an array of nested objects. so I was able to parse

3条回答
  •  醉酒成梦
    2021-01-29 01:16

    IF you want all addresses inside DistributionCentres

    Column(
           children: [
                Text(value[1]['Name']),
                Text(value[1]['Oid'].toString()),
                ListView.builder(
                itemCount:value[1]['DistributionCentres'].length
                context:context,
                builder:(BuilderContext context, int i){
                 return Text(value[1]['DistributionCentres'][i]['Address'])
                }))
              ],
            ),
    

    IF you want one address

    Text(value[1]['DistributionCentres'][1]['Address'])
    

    Like to remind for the value[1] you can pass the selected id from previous screen and used it here as value[selected id],

    Hope this helps..

提交回复
热议问题