class CalendarEvent { final int id; final String title; final DateTime startDt; final DateTime? endDt; final bool allDay; final String description; final String location; final String color; final String? recurrence; final int? projectId; final int? reminderMinutes; const CalendarEvent({ required this.id, required this.title, required this.startDt, this.endDt, required this.allDay, required this.description, required this.location, required this.color, this.recurrence, this.projectId, this.reminderMinutes, }); factory CalendarEvent.fromJson(Map json) => CalendarEvent( id: json['id'] as int, title: json['title'] as String? ?? '', startDt: DateTime.parse(json['start_dt'] as String).toLocal(), endDt: json['end_dt'] != null ? DateTime.parse(json['end_dt'] as String).toLocal() : null, allDay: json['all_day'] as bool? ?? false, description: json['description'] as String? ?? '', location: json['location'] as String? ?? '', color: json['color'] as String? ?? '', recurrence: json['recurrence'] as String?, projectId: json['project_id'] as int?, reminderMinutes: json['reminder_minutes'] as int?, ); } /// Strips time from a DateTime, returning midnight local. /// Used as map keys in CalendarState.eventsByDay. DateTime dateOnly(DateTime dt) => DateTime(dt.year, dt.month, dt.day);