Objects.fromJson constructor

Objects.fromJson(
  1. Map<String, dynamic> json
)

Implementation

Objects.fromJson(Map<String, dynamic> json) {
  height = double.tryParse(json['height'].toString()) ?? 0.0;
  id = json['id'];
  ellipse = json['ellipse'] ?? false;
  point = json['point'] ?? false;
  gid = int.tryParse(json['gid'].toString());
  name = json['name'];
  rotation = double.tryParse(json['rotation'].toString()) ?? 0.0;
  typeOrClass = json['type'] ?? json['class'];
  visible = json['visible'];
  width = double.tryParse(json['width'].toString()) ?? 0.0;
  x = double.tryParse(json['x'].toString()) ?? 0.0;
  y = double.tryParse(json['y'].toString()) ?? 0.0;
  if (json['text'] != null) {
    text = Text.fromJson(json['text']);
  }
  if (json['properties'] != null) {
    properties = <Property>[];
    json['properties'].forEach((v) {
      properties?.add(Property.fromJson(v));
    });
  }
  if (json['polygon'] != null) {
    polygon = <Polygon>[];
    json['polygon'].forEach((v) {
      polygon?.add(Polygon.fromJson(v));
    });
  }
  if (json['polyline'] != null) {
    polyline = <Polygon>[];
    json['polyline'].forEach((v) {
      polyline?.add(Polygon.fromJson(v));
    });
  }
}