nextWeekday method

DateTime nextWeekday(
  1. int targetWeekday
)

Returns the next occurrence of weekday (1=Mon … 7=Sun) after this date.

Implementation

DateTime nextWeekday(int targetWeekday) {
  var result = add(const Duration(days: 1));
  while (result.weekday != targetWeekday) {
    result = result.add(const Duration(days: 1));
  }
  return result;
}