I want to check if items in array existed and add new values from another array without overwriting element after reloading. I created such code:
//take from that array
List<int> list = [2, 3, 5];
// add to this array and check if this array already has the same element or not
List<int> newValueInt = [2, 6, 7];
list.forEach((item) {
if(!list.contains(item)){
newValueInt.add(item);
print(newValueInt);
}
});
and it shows me that print:
[2, 6, 7, 3]
[2, 6, 7, 3, 5]
2
Answers
to