【发布时间】:2019-11-03 00:36:49
【问题描述】:
我有 2 个对象列表,即 newList 和 oldList,如下所示:
新列表:[Object{id: -LhnrmWPWN2X_cWdIAQW, title: , category: abandoned, latitude: -17.8594103, longitude: 30.9615846}, Object{id: -LhnpMHQ3l288W28qoDW, title: , category: potholes, latitude: -17.8593472, longitude: 30.9614917}]
旧列表:[Object{id: -LhnpMHQ3l288W28qoDW, title: , category: potholes, latitude: -17.8593472, longitude: 30.9614917}]
问题是使用以下代码检查 newList 中的所有对象是否都在 oldList 中时使用 contains 不起作用:
newList.where((Object p) => !oldList.contains(p))
.map((Object obj) => print('\n\n\n\ntest \n$obj'))
.toList();
事实上,这段代码对于 newList 中对象的两个实例都返回 true。
我希望代码应该只对其中一个对象返回 true。
请帮忙。
【问题讨论】:
标签: list dictionary flutter contains