RecurrenceRule class

Defines a recurrence pattern for repeating events.

Supports complex recurrence rules including:

  • Daily, weekly, monthly, and yearly frequencies
  • Custom intervals (e.g., every 2 weeks)
  • Specific days of the week
  • Specific days of the month
  • Specific months
  • End conditions (never, until date, or after count)

Example:

// Every weekday (Monday-Friday)
final weekdayRule = RecurrenceRule(
  frequency: RecurrenceFrequency.weekly,
  byWeekDay: [1, 2, 3, 4, 5], // Mon-Fri
);

// Every 2 weeks on Monday and Wednesday, 10 times
final customRule = RecurrenceRule(
  frequency: RecurrenceFrequency.weekly,
  interval: 2,
  byWeekDay: [1, 3], // Monday and Wednesday
  endCondition: RecurrenceEnd.count(10),
);

Constructors

RecurrenceRule({required RecurrenceFrequency frequency, int interval = 1, List<int>? byWeekDay, List<int>? byMonthDay, List<int>? byMonth, RecurrenceEnd? endCondition})
Creates a recurrence rule.
RecurrenceRule.fromJson(Map<String, dynamic> json)
Creates a recurrence rule from JSON data.
factory

Properties

byMonth List<int>?
List of months when the event occurs (1-12).
final
byMonthDay List<int>?
List of days of the month when the event occurs (1-31).
final
byWeekDay List<int>?
List of weekdays when the event occurs (1=Monday, 7=Sunday).
final
endCondition RecurrenceEnd?
When the recurrence should end.
final
frequency RecurrenceFrequency
How often the event repeats.
final
hashCode int
The hash code for this object.
no setterinherited
interval int
The interval between occurrences (e.g., 2 for "every 2 weeks").
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

copyWith({RecurrenceFrequency? frequency, int? interval, List<int>? byWeekDay, List<int>? byMonthDay, List<int>? byMonth, RecurrenceEnd? endCondition}) RecurrenceRule
Creates a copy of this recurrence rule with the given fields replaced.
generateOccurrences(DateTime start, DateTime rangeStart, DateTime rangeEnd) List<DateTime>
Generates all event occurrences within a date range.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toJson() Map<String, dynamic>
Converts this recurrence rule to a JSON map.
toRRule() String
Converts this recurrence rule to an RRULE string (RFC 5545 format).
toString() String
A string representation of this object.
override

Operators

operator ==(Object other) bool
The equality operator.
inherited