fromDict method Null safety

Sp3dObj fromDict(
  1. Map<String, dynamic> src
)

Restore this object from the dictionary.

  • src : A dictionary made with toDict of this class.

Implementation

static Sp3dObj fromDict(Map<String, dynamic> src) {
  List<Sp3dV3D> v = [];
  for (var i in src['vertices']) {
    v.add(Sp3dV3D.fromDict(i));
  }
  List<Sp3dFragment> frgs = [];
  for (var i in src['fragments']) {
    frgs.add(Sp3dFragment.fromDict(i));
  }
  List<Sp3dMaterial> mtrs = [];
  for (var i in src['materials']) {
    mtrs.add(Sp3dMaterial.fromDict(i));
  }
  List<Uint8List> imgs = [];
  for (List<dynamic> i in src['images']) {
    List<int> iL = [];
    for (dynamic j in i) {
      iL.add(j as int);
    }
    imgs.add(Uint8List.fromList(iL));
  }
  return Sp3dObj(v, frgs, mtrs, imgs,
      id: src['id'],
      name: src['name'],
      author: src.containsKey('author') ? src['author'] : null,
      physics: src.containsKey('physics')
          ? src['physics'] != null
              ? Sp3dPhysics.fromDict(src['physics'])
              : null
          : null,
      option: src['option']);
}