feat: add table_calendar package and CalendarEvent model with tests

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-06 10:25:52 -04:00
parent 8a0837a843
commit b56c0fc02d
4 changed files with 132 additions and 0 deletions
+47
View File
@@ -0,0 +1,47 @@
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<String, dynamic> json) => CalendarEvent(
id: json['id'] as int,
title: json['title'] as String? ?? '',
startDt: DateTime.parse(json['start_dt'] as String),
endDt: json['end_dt'] != null
? DateTime.parse(json['end_dt'] as String)
: 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);