'How to select this inner json data list
i have dummy json and i want to target the inner list and return several widget with that list data. The data i want to get is 'content', for example i want to return a few cards with 'content' data,
Card 1 = 'Full Name'
Card 2 = 'Email Address'
Card 3 = 'Phone Number'
my widget code
for (var i = 0; i < formPages[index + 1]['content'].length; i++)
Container(
margin: EdgeInsets.fromLTRB(24, 20, 24, 0),
color: Colors.grey,
width: double.infinity,
height: 30,
child: Text(
formPages[index + 1]['content'][0]['question']),
),
dummy json
{
'page': 2,
'part': 1,
'title': 'General Information',
'content': [
{
'question_type': 'text_box',
'question': 'Full Name',
'option': [],
},
{
'question_type': 'text_box',
'question': 'Email Address',
'option': [],
},
{
'question_type': 'text_box',
'question': 'Phone Number',
'option': [],
},
]
}
Solution 1:[1]
for (var i = 0; i < formPages[index + 1]['content'].length; i++)
Container(
margin: EdgeInsets.fromLTRB(24, 20, 24, 0),
color: Colors.grey,
width: double.infinity,
height: 30,
child: Text(
formPages[index + 1]['content']['question'][i]),
),
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Hammad Ali |