CalendarEvent class
Base class for events displayed in the calendar.
Stores a UTC date range, a unique id, and an interaction config. Extend this class to attach custom data (title, color, etc.).
class Event extends CalendarEvent {
Event({required super.dateTimeRange, required this.title, super.interaction});
final String title;
@override
Event copyWith({DateTimeRange? dateTimeRange, EventInteraction? interaction, String? title}) =>
Event(
dateTimeRange: dateTimeRange ?? this.dateTimeRange,
interaction: interaction ?? this.interaction,
title: title ?? this.title,
)..id = id;
@override
bool operator ==(Object other) =>
super == other && other is Event && other.title == title;
@override
int get hashCode => Object.hash(super.hashCode, title);
}
Constructors
-
CalendarEvent({String? id, required DateTimeRange<
DateTime> dateTimeRange, EventInteraction? interaction}) - Creates a CalendarEvent.
Properties
-
dateTimeRange
→ DateTimeRange<
DateTime> -
The date range as a DateTimeRange.
no setter
- duration → Duration
-
Total duration (UTC-based).
no setter
- end → DateTime
-
The end of the event in UTC.
final
- hashCode → int
-
The hash code for this object.
no setteroverride
- id ↔ String
-
Unique identifier. Auto-generated if not provided.
getter/setter pair
- interaction → EventInteraction
-
Controls whether the event can be moved, resized, etc.
final
- isMultiDayEvent → bool
-
Whether this event spans more than one day.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- start → DateTime
-
The start of the event in UTC.
final
Methods
-
copyWith(
{DateTimeRange< DateTime> ? dateTimeRange, EventInteraction? interaction}) → CalendarEvent - Returns a copy with the given fields replaced.
-
datesSpanned(
{Location? location}) → List< InternalDateTime> -
All dates this event spans, adjusted for
location. -
internalEnd(
{Location? location}) → InternalDateTime -
The end as an InternalDateTime, adjusted for
location. -
internalRange(
{Location? location}) → InternalDateTimeRange -
The full range as an InternalDateTimeRange, adjusted for
location. -
internalStart(
{Location? location}) → InternalDateTime -
The start as an InternalDateTime, adjusted for
location. -
layoutEquals(
CalendarEvent other) → bool - Compares layout-affecting properties (id, start, end, interaction).
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
override
Operators
-
operator ==(
Object other) → bool -
Check equality based on layoutEquals.
override