I try to modify an object:
void main() {
  
  Model item = Model(list: [3,4]);
  print(item.list);
  Model test = item;
  List modifyList = test.list!;
  modifyList[0] = 999;
  test = Model(list: modifyList);
  print("original: " + item.list.toString());
  print("modified: " + test.list.toString());
  
}
  
  class Model {
  String? title;
  String? postid;
  List? list;
  Model({
    this.title,
    this.postid,
    this.list,
  });
    
    
}
this prints:
[3, 4]
original: [999, 4]
modified: [999, 4]
I dont understand why the first parameter of the original test model is also modified. How can I modify only the test model and keep the original?
Whats the reason for modifying the original variable even though I have previously put it to the new test?
 
    