List<Map<String, dynamic>> a=[{'a': 'Ram1', 'b': 'a+'},{'a': 'Ram2', 'b': 'a-'},{'a': 'Ram3', 'b': 'b-'},{'a': 'Ram4', 'b': 'ab+'},{'a': 'Ram5', 'b': 'ab-'}];
List<Map<String, dynamic>> b=[{'a': 'Ram1', 'b': 'a+'},{'a': 'Ram2', 'b': 'a-'}];
List<Map<String, dynamic>> c=List.from(a);
a.forEach((elementA) {
b.forEach((elementB) {
int keysMatched = 0;
elementB.keys.forEach((key) {
if(elementA.containsKey(key) && elementA[key] == elementB[key]){
keysMatched++;
}
});
if(keysMatched == elementB.keys.length){
c.remove(elementA);
}
});
});
print(c); // [{a: Ram3, b: b-}, {a: Ram4, b: ab+}, {a: Ram5, b: ab-}]
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…