nextCourseIndex function

int? nextCourseIndex(
  1. List<CourseScheduleMeeting> meetings, {
  2. required DateTime now,
})

Selects the first course that has not started yet.

Returns null when every course in meetings has already started.

Implementation

int? nextCourseIndex(
  List<CourseScheduleMeeting> meetings, {
  required DateTime now,
}) {
  final index = meetings.indexWhere((meeting) => meeting.start.isAfter(now));
  return index < 0 ? null : index;
}