update
This commit is contained in:
@@ -51,6 +51,14 @@ class EventModel {
|
||||
final String? eventStatus;
|
||||
final String? cancelledReason;
|
||||
|
||||
// Geo / location fields
|
||||
final double? latitude;
|
||||
final double? longitude;
|
||||
final String? locationName;
|
||||
|
||||
// Structured important info list [{title, value}, ...]
|
||||
final List<Map<String, String>> importantInfo;
|
||||
|
||||
EventModel({
|
||||
required this.id,
|
||||
required this.name,
|
||||
@@ -70,8 +78,36 @@ class EventModel {
|
||||
this.venueName,
|
||||
this.eventStatus,
|
||||
this.cancelledReason,
|
||||
this.latitude,
|
||||
this.longitude,
|
||||
this.locationName,
|
||||
this.importantInfo = const [],
|
||||
});
|
||||
|
||||
/// Safely parse a double from backend (may arrive as String or num)
|
||||
static double? _parseDouble(dynamic raw) {
|
||||
if (raw == null) return null;
|
||||
if (raw is num) return raw.toDouble();
|
||||
if (raw is String) return double.tryParse(raw);
|
||||
return null;
|
||||
}
|
||||
|
||||
/// Safely parse important_info from backend (list of {title, value} maps)
|
||||
static List<Map<String, String>> _parseImportantInfo(dynamic raw) {
|
||||
if (raw is List) {
|
||||
return raw.map<Map<String, String>>((e) {
|
||||
if (e is Map) {
|
||||
return {
|
||||
'title': (e['title'] ?? '').toString(),
|
||||
'value': (e['value'] ?? '').toString(),
|
||||
};
|
||||
}
|
||||
return {'title': '', 'value': e.toString()};
|
||||
}).toList();
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
||||
factory EventModel.fromJson(Map<String, dynamic> j) {
|
||||
final imgs = <EventImageModel>[];
|
||||
if (j['images'] is List) {
|
||||
@@ -99,6 +135,10 @@ class EventModel {
|
||||
venueName: j['venue_name'] as String?,
|
||||
eventStatus: j['event_status'] as String?,
|
||||
cancelledReason: j['cancelled_reason'] as String?,
|
||||
latitude: _parseDouble(j['latitude']),
|
||||
longitude: _parseDouble(j['longitude']),
|
||||
locationName: j['location_name'] as String?,
|
||||
importantInfo: _parseImportantInfo(j['important_info']),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user