toDict method Null safety

Map<String, dynamic> toDict()

Convert the object to a dictionary.

Implementation

Map<String, dynamic> toDict() {
  Map<String, dynamic> d = {};
  d['class_name'] = this.className;
  d['version'] = this.version;
  List<Map<String, dynamic>> v = [];
  for (var i in this.vertices) {
    v.add(i.toDict());
  }
  d['vertices'] = v;
  List<Map<String, dynamic>> frgs = [];
  for (var i in this.fragments) {
    frgs.add(i.toDict());
  }
  d['fragments'] = frgs;
  List<Map<String, dynamic>> mtrs = [];
  for (var i in this.materials) {
    mtrs.add(i.toDict());
  }
  d['materials'] = mtrs;
  List<List<int>> imgs = [];
  for (Uint8List i in this.images) {
    List<int> il = [];
    for (var j in i) {
      il.add(j);
    }
    imgs.add(il);
  }
  d['images'] = imgs;
  d['id'] = this.id;
  d['name'] = this.name;
  d['author'] = this.author;
  d['physics'] = this.physics != null ? this.physics!.toDict() : null;
  d['option'] = this.option;
  return d;
}