class TranslationModel { final int id; final String language; final String title; final String? markdown; TranslationModel({ required this.id, required this.language, required this.title, this.markdown, }); Map toJson() { return { 'id': id, 'language': language, 'title': title, 'markdown': markdown, }; } factory TranslationModel.fromJson(Map json) { return TranslationModel( id: json['id'] ?? 0, language: json['language'] ?? '', title: json['title'] ?? '', markdown: json['markdown'] ?? '', ); } } class ConferencesModel { final int id; final String title; final DateTime date; int activity; int duration; String place; String city; String state; String country; // List type; String thumbnail; List translations; ConferencesModel({ required this.id, required this.title, required this.date, this.activity = 0, this.duration = 0, this.place = '', this.city = '', this.state = '', this.country = '', // this.type = const [], this.thumbnail = '', this.translations = const [], }); Map toJson() { return { 'id': id, 'title': title, 'date': date.toIso8601String(), 'activity': activity, 'duration': duration, 'place': place, 'city': city, 'state': state, 'country': country, // 'type': type, 'thumbnail': thumbnail.toString(), 'translations': translations.toString() , }; } factory ConferencesModel.fromJson(Map json) { return ConferencesModel( id: json['id'] ?? 0, title: json['title'] ?? '', date: json['date'] != null ? DateTime.parse(json['date'].toString()) : DateTime.now(), activity: json['activity'] ?? 0, duration: json['duration'] ?? 0, place: json['place'] ?? '', city: json['city'] ?? '', state: json['state'] ?? '', country: json['country'] ?? '', // type: List.from(json['type'] ?? []), thumbnail: json['thumbnail'] ?? '', translations: (json['translations'] as List?) ?.map((item) => TranslationModel.fromJson(item as Map)) .toList() ?? [], ); } }