Reputation: 336
I have a List which in this List the second element of map is another list I want have ListView of element in first List and a GridView of second or inner List How should I do this.
List<Map<String, Object>> myList = [
{
'title': 'first',
'icon': [
item1,
item2,
item3,
item4,
item5,
],
},
{
'title': 'second',
'icon': [
item1,
item2,
item3,
item4,
item5,
],
},
];
Upvotes: 1
Views: 68
Reputation: 5422
You need to cast the 'icon' value to a List<YourType>
and then iterate from there.
List<Map<String, Object>> myList = [
{
'title': 'first',
'icon': [
"item1",
"item2",
"item3",
"item4",
"item5",
],
},
{
'title': 'second',
'icon': [
"item1",
"item2",
"item3",
"item4",
"item5",
],
},
];
myList.forEach((element) {
(element['icon'] as List<String>).forEach((innerElement) {
print(innerElement);
});
});
Upvotes: 2