toString method
Gets an English readable string representation of the interval pattern.
Implementation
@override
String toString({bool includeStartDate = false}) {
String description = 'Every ';
switch (interval) {
case Intervals.once:
return 'Once on ${DateFormat.yMMMMd().format(startDate)}';
case Intervals.daily:
description += period > 1 ? '$period days' : 'day';
break;
case Intervals.weekly:
description += period > 1 ? '$period weeks' : 'week';
description += ' on ' + startDate.dayOfWeek;
break;
case Intervals.monthly:
description += period > 1 ? '$period months' : 'month';
description += ' on the ' + startDate.dayOfMonth;
break;
case Intervals.yearly:
description += period > 1 ? '$period years' : 'year';
description += ' on ${DateFormat.MMMMd().format(startDate)}';
break;
}
if (includeStartDate) {
description += ', beginning on ${DateFormat.yMMMMd().format(startDate)}';
}
return description;
}