last method
Returns the last date in the list of dates, ignoring null values.
Implementation
DateTime? last(Iterable<DateTime?>? dates) {
if (dates == null) return null;
final filteredDates = dates.whereType<DateTime>();
if (filteredDates.isEmpty) return null;
return filteredDates.reduce((a, b) => a.isAfter(b) ? a : b);
}