nextDate property

DateTime get nextDate

Returns the next date of this weekday.

If this weekday is today, DateTime.now() is returned.

Implementation

DateTime get nextDate {
  final now = DateTime.now();
  for (var i = 0; i < 7; i++) {
    final date = now.add(Duration(days: i));
    if (date.weekday == index + 1) {
      return date;
    }
  }
  throw StateError('Could not find next date for $this');
}