Models API Reference

Immutable data models with serialization, equality, and domain logic.

EventModel

lib/models/event_model.dart

The core domain object representing a calendar event. Immutable with copyWith() for derived copies.

Constructor

EventModel({ required String id, required String title, String description = '', required DateTime date, EventPriority priority = EventPriority.medium, List<EventTag>? tags, RecurrenceRule? recurrence, })

Properties

PropertyTypeDescription
idStringUnique identifier
titleStringEvent title
descriptionStringEvent description (default: empty)
dateDateTimeEvent date/time
priorityEventPriorityPriority level (low, medium, high, urgent)
tagsList<EventTag>Category tags (default: empty)
recurrenceRecurrenceRule?Recurrence rule (null = non-recurring)
isRecurringboolComputed: whether event has a recurrence rule

Methods

MethodReturnsDescription
copyWith({...})EventModelCreates a copy with specified fields replaced. Use clearRecurrence: true to remove recurrence.
generateOccurrences({maxOccurrences})List<EventModel>Generates future recurring instances with derived IDs (originalId_N). Returns empty if not recurring.
fromJson(Map)EventModelFactory: deserializes from JSON/SQLite row. Handles both String and List tag formats.
toJson()Map<String, dynamic>Serializes for SQLite storage. Tags are JSON-encoded as a string.

EventPriority

Enum with four levels, each carrying display metadata:

ValueLabelColorIcon
lowLow๐ŸŸข Greenโ†“ arrow_downward
mediumMedium๐ŸŸ  Orangeโ€” remove
highHigh๐Ÿ”ด Deep Orangeโ†‘ arrow_upward
urgentUrgent๐Ÿ”ด Redโ— priority_high

Methods

MethodDescription
labelHuman-readable display string
colorAssociated Material Color
iconAssociated Material IconData
fromString(String)Parse from stored name. Falls back to medium.

EventTag

lib/models/event_tag.dart

Color-coded categorization for events. Equality is based on name (case-insensitive).

Constructor

EventTag({ required String name, int colorIndex = 0, })

Color Palette

IndexColorName
0๐Ÿ”ตBlue
1๐ŸŸขGreen
2๐ŸŸ Orange
3๐ŸŸฃPurple
4๐Ÿ’—Pink
5๐ŸฉตCyan
6๐ŸŸคBrown
7โฌœBlue Grey

Preset Tags

Static list of common tags: Work (blue), Personal (green), Meeting (orange), Birthday (purple), Health (pink), Travel (cyan), Finance (brown), Social (grey).

RecurrenceRule

lib/models/recurrence_rule.dart

Defines how an event repeats. Generates occurrence dates with smart month-length clamping.

Constructor

RecurrenceRule({ required RecurrenceFrequency frequency, int interval = 1, DateTime? endDate, })

Properties

PropertyTypeDescription
frequencyRecurrenceFrequencydaily, weekly, monthly, yearly
intervalintRepeat every N periods (default: 1)
endDateDateTime?Optional end date (null = infinite)
summaryStringComputed: "Every 2 weeks until Mar 15, 2026"

Methods

MethodDescription
generateOccurrences(startDate, {maxOccurrences: 52})Returns list of DateTimes. Stops at endDate or max count.
fromJson(Map) / toJson()Standard JSON serialization
fromJsonString(String?) / toJsonString()String-based serialization for SQLite TEXT columns
Month Clamping Adding months respects varying month lengths. For example, Jan 31 + 1 month = Feb 28 (or 29 in leap years). This prevents DateTime overflow errors.

UserModel

lib/models/user_model.dart

Simple user identity model with JSON serialization. Persisted to the users SQLite table for session restoration.

Fields

FieldTypeDescription
idStringFirebase UID
nameStringDisplay name
emailStringEmail address