import 'package:hiddingsel_app/appflow/model/schedules.dart'; import 'package:hiddingsel_app/services/storage.dart'; import 'contacts.dart'; import 'event_organisations.dart'; import 'interfaces.dart'; class EventModel with Name, Contact, JsonEncodable { final String id; final ScheduleModel schedule; final String name; final ContactModel contact; final String? description; List eventOrganizer; EventModel(this.id, this.schedule, this.name, this.contact, {this.description, List? eventOrganizer}) : this.eventOrganizer = eventOrganizer ?? []; factory EventModel.fromJson(Map json) => EventModel( json['id'] as String, ScheduleModel.fromJson(json['schedule'] as Map), json['name'] as String, ContactModel.fromJson(json['contact'] as Map), description: json['description'] as String?, eventOrganizer: (json['eventOrganizer'] as List).map((id) => EventOrganisationModel.fromId(id)).cast().toList(), ); Map toJson() => { 'id': id, 'schedule': schedule.toJson(), 'name': name, 'contact': contact.toJson(), 'description': description, 'eventOrganizer': eventOrganizer.map((e) => e.id).toList(), }; @override bool operator ==(Object other) => other is EventModel && runtimeType == other.runtimeType && (id == other.id || (schedule.startTime == other.schedule.startTime && name == other.name)); @override int get hashCode => id.hashCode; }