import 'dart:convert'; class Agenda { List events; Agenda({required this.events}); factory Agenda.fromJson(String jsonString) { final List jsonList = json.decode(jsonString); List events = []; for (var eventData in jsonList) { try { events.add(EventAgenda.fromJson(eventData)); } catch(e) { print("Erreur lors du parsing du json : ${e.toString()}"); } } return Agenda(events: events); } } class EventAgenda { String? name; String? description; String? type; DateTime? dateAdded; DateTime? dateFrom; DateTime? dateTo; String? dateHour; EventAddress? address; String? website; String? phone; String? idVideoYoutube; String? email; String? image; EventAgenda({ required this.name, required this.description, required this.type, required this.dateAdded, required this.dateFrom, required this.dateTo, required this.dateHour, required this.address, required this.website, required this.phone, required this.idVideoYoutube, required this.email, required this.image, }); factory EventAgenda.fromJson(Map json) { return EventAgenda( name: json['name'], description: json['description'], type: json['type'] is !bool ? json['type'] : null, dateAdded: json['date_added'] != null && json['date_added'].isNotEmpty ? DateTime.parse(json['date_added']) : null, dateFrom: json['date_from'] != null && json['date_from'].isNotEmpty ? DateTime.parse(json['date_from']) : null, dateTo: json['date_to'] != null && json['date_to'].isNotEmpty ? DateTime.parse(json['date_to']) : null, dateHour: json['date_hour'], address: json['address'] is !bool ? EventAddress.fromJson(json['address']) : null, website: json['website'], phone: json['phone'], idVideoYoutube: json['id_video_youtube'], email: json['email'], image: json['image'], ); } } class EventAddress { String? address; dynamic lat; dynamic lng; int? zoom; String? placeId; String? name; String? streetNumber; String? streetName; String? streetNameShort; String? city; String? state; String? stateShort; String? postCode; String? country; String? countryShort; EventAddress({ required this.address, required this.lat, required this.lng, required this.zoom, required this.placeId, required this.name, required this.streetNumber, required this.streetName, required this.streetNameShort, required this.city, required this.state, required this.stateShort, required this.postCode, required this.country, required this.countryShort, }); factory EventAddress.fromJson(Map json) { return EventAddress( address: json['address'], lat: json['lat'], lng: json['lng'], zoom: json['zoom'], placeId: json['place_id'], name: json['name'], streetNumber: json['street_number'], streetName: json['street_name'], streetNameShort: json['street_name_short'], city: json['city'], state: json['state'], stateShort: json['state_short'], postCode: json['post_code'], country: json['country'], countryShort: json['country_short'], ); } }