Is there a Language supported way make a full (deep) copy of an Object in Dart?
Secondary only; are there multiple ways of doing this, and what are the differences?
Thanks for clarification!
Is there a Language supported way make a full (deep) copy of an Object in Dart?
Secondary only; are there multiple ways of doing this, and what are the differences?
Thanks for clarification!
Late to the party, but I recently faced this problem and had to do something along the lines of :-
Calling RandomObject.clone seems to do something similar. This can be added to an abstract class so that you can create generic builders of objects.
Darts built-in collections use a named constructor called "from" to accomplish this. See this post: Clone a List, Map or Set in Dart
No as far as open issues seems to suggest:
http://code.google.com/p/dart/issues/detail?id=3367
And specifically:
I guess for not-too-complex objects, you could use the convert library:
and then use the JSON encode/decode functionality
If you're using a custom class as a value in the object to clone, the class either needs to implement a toJson() method or you have to provide a toEncodable function for the JSON.encode method and a reviver method for the decode call.