How can I clone an Object (deep copy) in Dart?

george koller picture george koller · Oct 28, 2012 · Viewed 43.9k times · Source

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!

Answer

computmaxer picture computmaxer · Feb 17, 2015

Darts built-in collections use a named constructor called "from" to accomplish this. See this post: Clone a List, Map or Set in Dart

Map mapA = {
    'foo': 'bar'
};
Map mapB = new Map.from(mapA);