Reputation: 3049
I have two type of list. Here,
List list1= [
{"id": "3", "topic_name": "Studying In Bangladesh"},
{"id": "4", "topic_name": "Studying In Sweden"},
{"id": "6", "topic_name": "Studying In Germany"},
];
List list2 = [
"2",
"3",
"5",
"6",
];
I want to generate a new topic list from list1, which is matched by list2's elements ( with list1's id ).
Is there any method are available for dart ?
Upvotes: 0
Views: 174
Reputation: 369
You can compare list1's id element with the list 2 with the foreach property in list for iterate through all elements of the list
Upvotes: 0
Reputation: 23164
You can do this:
List list3 = list1.where((e) => list2.contains(e['id'])).toList();
Upvotes: 1