I've two Lists Of myContactsModal in Object i.e
List<myContactsModel> allContacts=[myContactsModel(displayName: "ABC",
phoneNumbers: "1234"),myContactsModel(displayName: "EFG",
phoneNumbers: "12345"),myContactsModel(displayName: "Test",
phoneNumbers: "78923")];
List<myContactsModel> chekList =[myContactsModel(displayName: "ABC",
phoneNumbers: "8973"),myContactsModel(displayName: "BHGS",
phoneNumbers: "12347872")];
What I want to achieve is compare these two lists and if element in checkLists having same displayName exists in allContacts array i want to update that element in allContacts List and If it doesnt exists in allContacts list Then It should add new entry in allContacts List. The Output Should Be:
List<myContactsModel>allContacts=[
myContactsModel(displayName: "ABC",
phoneNumbers: "8973"),
myContactsModel(displayName: "EFG",
phoneNumbers: "12345"),
myContactsModel(displayName: "Test",
phoneNumbers: "78923"),
myContactsModel(displayName: "BHGS",
phoneNumbers: "12347872")
]