Here is a dummy sample of my poor man's spread operator pattern:
I make a copy constructor for classes often re-created with slight modifications.It is extra work during definition, but it pays off at many locations when using these classes. The same pattern can be used on standard classes by subclassing -- just to connect to the specific question.
class Address { final String street; final String city; final String state; Address({this.street, this.city, this.state}); Address.copy(Address copy, { String street, String city, String state, }) : this ( street: street ?? copy.street, city: city ?? copy.city, state: state ?? copy.state, );}class User { final String firstName; final String lastName; final Address address; final String email; User({this.firstName, this.lastName, this.address, this.email}); User.copy(User copy, { String firstName, String lastName, Address address, String email, }) : this ( firstName: firstName ?? copy.firstName, lastName: lastName ?? copy.lastName, address: address ?? copy.address, email: email ?? copy.email, );}void workWithUsers(User user) { final userChangedEmail = User.copy(user, email: 'new@email.com'); final userMovedToAnotherStreet = User.copy(user, address: Address.copy(user.address, street: 'Newstreet'));}