Tony
Tony

Reputation: 2748

get itemCount from a list

I have this json structure

  "abc":{
        current_checklist:[
        {
         .... 
        },
        {
          "sections":[
              ...
           ]
        },
        {
             ...         
        }
     ]
  }

I want to use ListView, where the itemCount is based on sections. How should I write it?

Widget _displayCheckList(ABCData abcData) {
    return ListView.builder(
      physics: NeverScrollableScrollPhysics(),
      shrinkWrap: true,
      itemCount:
          abcData.abc.currentChecklist.???,length,  // how to get the "sections" length? 
      itemBuilder: (context, index) {
        return Text("Hello");
      },
    );
  }
}

Upvotes: 2

Views: 174

Answers (1)

bluenile
bluenile

Reputation: 6029

Would have been good to see some valid sample json data.

Did you try something like :

abcData.abc.currentChecklist[0].sections or
abcData.abc.currentChecklist[1].sections

Upvotes: 1

Related Questions