fromDict static method

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

Restore this object from the dictionary.

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

Implementation

static Sp3dMaterial fromDict(Map<String, dynamic> src) {
  var mbg =
      Color.fromARGB(src['bg'][0], src['bg'][1], src['bg'][2], src['bg'][3]);
  var msc = Color.fromARGB(src['stroke_color'][0], src['stroke_color'][1],
      src['stroke_color'][2], src['stroke_color'][3]);
  List<Offset>? tCoord;
  if (src.containsKey('texture_coordinates')) {
    if (src['texture_coordinates'] != null) {
      tCoord = [];
      List<double> cBuff = [];
      for (double d in src['texture_coordinates']) {
        cBuff.add(d);
        if (cBuff.length == 2) {
          tCoord.add(Offset(cBuff[0], cBuff[1]));
          cBuff.clear();
        }
      }
    }
  }
  // After version 7.
  String? mName;
  if (src.containsKey('name')) {
    mName = src['name'];
  }
  return Sp3dMaterial(mbg, src['is_fill'], src['stroke_width'], msc,
      imageIndex: src['image_index'],
      textureCoordinates: tCoord,
      name: mName,
      option: src['option']);
}