deepCopy method Null safety

Sp3dObj deepCopy()

Deep copy the object.

Implementation

Sp3dObj deepCopy() {
  List<Sp3dV3D> v = [];
  for (var i in this.vertices) {
    v.add(i.deepCopy());
  }
  List<Sp3dFragment> frgs = [];
  for (var i in this.fragments) {
    frgs.add(i.deepCopy());
  }
  List<Sp3dMaterial> mtrs = [];
  for (var i in this.materials) {
    mtrs.add(i.deepCopy());
  }
  List<Uint8List> imgs = [];
  for (Uint8List i in this.images) {
    List<int> il = [];
    for (var j in i) {
      il.add(j);
    }
    imgs.add(Uint8List.fromList(il));
  }
  return Sp3dObj(v, frgs, mtrs, imgs,
      id: this.id,
      name: this.name,
      author: this.author,
      physics: this.physics != null ? this.physics!.deepCopy() : null,
      option: this.option != null ? {...this.option!} : null);
}