-
The objects cloning section in the readme show how to make a copy of a mappable object with one of its properties changed. Is it possible to do that with nested properties? freezed, for example, allows cloning with changes in a lower level property: final cloneCar = car.copyWith.leftWheel.tire(thickness: 32); But dart_json_mappable's copyWith method only allows for one deep changes: final cloneCar = JsonMapper.copyWith(car, {'color': 'blue'}); // same object but blue If we were to change a deeper property like so: final cloneCar = JsonMapper.copyWith(car, {'leftWheel': {'tire': {'thickness': 32}}}); // replaces entire leftWheel It would replace the entirety of the top level property. If I was able to deep clone objects like above, then I could use mappable classes as immutable data classes. Is there any way to achieve this? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 7 replies
-
Sure, it's possible. Please refer this commit for a unit test demonstrating exactly that. |
Beta Was this translation helpful? Give feedback.
Sure, it's possible. Please refer this commit for a unit test demonstrating exactly that.