copyWith method

Recurrence copyWith({
  1. RecurrenceFrequency? frequency,
  2. DateTime? until,
  3. int? count,
  4. int? interval,
  5. List<int>? bySecond,
  6. List<int>? byMinute,
  7. List<int>? byHour,
  8. List<ByDayRule>? byWeekDay,
  9. List<int>? byYearDay,
  10. List<int>? byWeek,
  11. List<int>? byMonth,
  12. List<int>? byMonthDay,
  13. int? startOfWorkWeek,
  14. List<int>? bySetPos,
  15. bool copyByRules = true,
  16. bool copyUntil = true,
})

Copies this recurrence rule with the given attributes.

Set copyByRules to false to not copy any by-rules. This defaults to true, meaning by rules are copied by default.

Set copyUntil to false to not copy the until attribute. This defaults to true, meaning the until attribute is copied by default.

Implementation

Recurrence copyWith({
  RecurrenceFrequency? frequency,
  DateTime? until,
  int? count,
  int? interval,
  List<int>? bySecond,
  List<int>? byMinute,
  List<int>? byHour,
  List<ByDayRule>? byWeekDay,
  List<int>? byYearDay,
  List<int>? byWeek,
  List<int>? byMonth,
  List<int>? byMonthDay,
  int? startOfWorkWeek,
  List<int>? bySetPos,
  bool copyByRules = true,
  bool copyUntil = true,
}) {
  if (!copyByRules) {
    return Recurrence(
      frequency ?? this.frequency,
      until: until ?? (copyUntil ? this.until : null),
      count: count ?? this.count,
      interval: interval ?? _interval,
      startOfWorkWeek: startOfWorkWeek ?? _startOfWorkWeek,
      bySecond: bySecond,
      byMinute: byMinute,
      byHour: byHour,
      byWeekDay: byWeekDay,
      byMonthDay: byMonthDay,
      byYearDay: byYearDay,
      byWeek: byWeek,
      byMonth: byMonth,
      bySetPos: bySetPos,
    );
  }

  return Recurrence(
    frequency ?? this.frequency,
    until: until ?? (copyUntil ? this.until : null),
    count: count ?? this.count,
    interval: interval ?? _interval,
    startOfWorkWeek: startOfWorkWeek ?? _startOfWorkWeek,
    bySecond: bySecond ?? this.bySecond,
    byMinute: byMinute ?? this.byMinute,
    byHour: byHour ?? this.byHour,
    byWeekDay: byWeekDay ?? this.byWeekDay,
    byMonthDay: byMonthDay ?? this.byMonthDay,
    byYearDay: byYearDay ?? this.byYearDay,
    byWeek: byWeek ?? this.byWeek,
    byMonth: byMonth ?? this.byMonth,
    bySetPos: bySetPos ?? this.bySetPos,
  );
}