Home > Mobile >  getting issue in Dart
getting issue in Dart

Time:03-21

I'm adding and removing data in one list and the second list is also affecting

This is the result I'm getting:

CodePudding user response:

If you have code like this:

list1 = [];
list2 = list1;

this error is normal. You need give more information about this issue.

CodePudding user response:

You certainly have a line like this:

_tempccToListSelected = _ccToListSelected;

or the opposite.

This line don't copy list into another one but make a pointer to the other list (like in numerous language).

If you want to copy (duplicate) the liste use spread operator:

_tempccToListSelected = [..._ccToListSelected];
  • Related