43 lines
1.2 KiB
Dart

class Events {
String? id;
String? name;
String? place;
String? startDate;
String? endDate;
String? description;
double? latitude;
double? longitude;
List<String>? tags;
List<String>? organizers;
String? imgUrl;
Events(
{this.place,
this.id,
this.name,
this.startDate,
this.description,
this.endDate,
this.tags,
this.latitude,
this.longitude,
this.organizers,
this.imgUrl});
Events.fromJson(Map<String, dynamic> json) {
id = json['id'] as String?;
name = json['name'] as String?;
place = json['place'] as String?;
startDate = json['start_date'] as String?;
endDate = json['end_date'] as String?;
description = json['description'] as String?;
latitude = (json['latitude'] as num?)?.toDouble(); // Safely cast to double
longitude =
(json['longitude'] as num?)?.toDouble(); // Safely cast to double
tags = (json['tags'] as List<dynamic>?)
?.cast<String>(); // Convert List<dynamic> to List<String>
organizers = (json['organizers'] as List<dynamic>?)
?.cast<String>(); // Convert List<dynamic> to List<String>
imgUrl = json['imgUrl'] as String?;
}
}