first method

DateTime? first(
  1. Iterable<DateTime?>? dates
)

Returns the first date in the list of dates, ignoring null values.

Implementation

DateTime? first(Iterable<DateTime?>? dates) {
  if (dates == null) return null;
  final filteredDates = dates.whereType<DateTime>();
  if (filteredDates.isEmpty) return null;
  return filteredDates.reduce((a, b) => a.isBefore(b) ? a : b);
}