Firstly, I have two models like this:
class Task {
final int id;
final String title;
final List<User> users;
}
class User {
final int id;
final String name;
}
I have the original Task object let call it A, and I make a copy called B so that I can reset B to A if user make a mistake and wants to retrieve the original one. Here is the copy :
Task a = Task(
id:0,
title: 'Task 1',
users: [
User(
id:1,
name: 'John',
),
],
);
Task b = Task(
id: a.id,
title: a.title,
user: List<User>.from(a.users),
);
When I update b.id and b.title there is no problems, if I reset my object it come back to a data.
But if I update the user name of user with the id 1 on B, it updates the user on A. I don't understand why ?