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

前端 未结 11 2289
谎友^
谎友^ 2020-12-01 13:22

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?<

11条回答
  •  -上瘾入骨i
    2020-12-01 13:58

    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);
    

提交回复
热议问题