ResoCoder / flutter-tdd-clean-architecture-course

https://resocoder.com/flutter-clean-architecture-tdd/
2.01k stars 625 forks source link

Question - Immutable and Equatable #22

Open nhwilly opened 4 years ago

nhwilly commented 4 years ago

I am using equatable as you describe in your course.

How do you manage when one class contains another and the contained class gets updated?

All the examples I find use a copyWith approach with non-positional arguments.

Is this the best practices way to do it?

TIA

cervonwong commented 4 years ago

Yes. The the containing class will not know that there is a new, updated instance of the contained class. So you will have to update the containing class by passing the updated contained class through the copyWith method.