Advertisement
Guest User

Untitled

a guest
Jun 20th, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.39 KB | None | 0 0
  1. void main() {
  2. List<dynamic> box1 = [{'id': 1, 'name': 'john'}, {'id': 2, 'name': 'eric'}] ;
  3. List<dynamic> box2 = [{'id': 1, 'name': 'eric'}, {'id': 2, 'name': 'alex'}, {'id': 3, 'name': 'john'}];
  4.  
  5. var commons = List();
  6.  
  7. box1.forEach((b1) {
  8. box2.forEach((b2) {
  9. if(b1['name'] == b2['name'] && !commons.contains(b2['name'])) commons.add(b2);
  10. });
  11. });
  12.  
  13. print(commons);
  14. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement