toJson method

Map<String, dynamic> toJson()

Implementation

Map<String, dynamic> toJson() {
  // Lists cannot be automatically be generated, this is why this method is convoluted
  Map<String, dynamic> pointsMap = {};
  graph.forEach((k, v) {
    if (v.isNotEmpty) {
      for (var element in v) {
        pointsMap[k.id] = element.toJson();
      }
    } else {
      pointsMap[k.id] = {};
    }
  });

  return {'graph': pointsMap};
}