toJson method

Map<String, dynamic> toJson()

Implementation

Map<String, dynamic> toJson() {
  // Lists cannot be automatically be generated, this is why this method is convoluted
  List<dynamic> beaconsList = [];
  for (var element in beacons) {
    beaconsList.add(element.toJson());
  }

  List<dynamic> roomsList = [];
  for (var element in rooms) {
    roomsList.add(element.toJson());
  }

  List<dynamic> landmarksList = [];
  if (landmarks != null) {
    for (var element in landmarks!) {
      landmarksList.add(element.toJson());
    }
  }

  return {
    'area': area.toJson(),
    'floorNumber': floorNumber,
    'beacons': beaconsList,
    'rooms': roomsList,
    'landmarks': landmarksList
  };
}