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
Properties
| Property | Type | Description |
|---|---|---|
id | String | Unique identifier |
title | String | Event title |
description | String | Event description (default: empty) |
date | DateTime | Event date/time |
priority | EventPriority | Priority level (low, medium, high, urgent) |
tags | List<EventTag> | Category tags (default: empty) |
recurrence | RecurrenceRule? | Recurrence rule (null = non-recurring) |
isRecurring | bool | Computed: whether event has a recurrence rule |
Methods
| Method | Returns | Description |
|---|---|---|
copyWith({...}) | EventModel | Creates 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) | EventModel | Factory: 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:
| Value | Label | Color | Icon |
|---|---|---|---|
low | Low | ๐ข Green | โ arrow_downward |
medium | Medium | ๐ Orange | โ remove |
high | High | ๐ด Deep Orange | โ arrow_upward |
urgent | Urgent | ๐ด Red | โ priority_high |
Methods
| Method | Description |
|---|---|
label | Human-readable display string |
color | Associated Material Color |
icon | Associated 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
Color Palette
| Index | Color | Name |
|---|---|---|
| 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
Properties
| Property | Type | Description |
|---|---|---|
frequency | RecurrenceFrequency | daily, weekly, monthly, yearly |
interval | int | Repeat every N periods (default: 1) |
endDate | DateTime? | Optional end date (null = infinite) |
summary | String | Computed: "Every 2 weeks until Mar 15, 2026" |
Methods
| Method | Description |
|---|---|
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 |
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
| Field | Type | Description |
|---|---|---|
id | String | Firebase UID |
name | String | Display name |
email | String | Email address |