I have programmed this little example so that you understand my problem. I make a copy of a list and I am eliminating values from the copy but they are also eliminated from the original. Why does this happen?
The error is: Uncaught Error: Concurrent modification during iteration: Instance of 'JSArray'.
void main()
{
List<String> list1 = ['jose', 'maria', 'eduardo','emiliano','paula'];
List<String> list2 = [];
list2 = list1;
for(var name in list1)
{
String nameAux = name;
print(nameAux);
list2.removeLast();
}
}
I need the original list not to remove the elements like the copy
Thanks