getVisibleDates function Null safety

List getVisibleDates(
  1. dynamic date,
  2. List<int>? nonWorkingDays,
  3. int firstDayOfWeek,
  4. int visibleDatesCount
)

Get the visible dates based on the date value and visible dates count.

Implementation

// ignore: always_specify_types
List getVisibleDates(dynamic date, List<int>? nonWorkingDays,
    int firstDayOfWeek, int visibleDatesCount) {
  // ignore: always_specify_types
  List datesCollection;
  if (date is HijriDateTime) {
    datesCollection = <HijriDateTime>[];
  } else {
    datesCollection = <DateTime>[];
  }

  final dynamic currentDate =
      getFirstDayOfWeekDate(visibleDatesCount, date, firstDayOfWeek);

  for (int i = 0; i < visibleDatesCount; i++) {
    final dynamic visibleDate = addDays(currentDate, i);
    if (nonWorkingDays != null &&
        nonWorkingDays.contains(visibleDate.weekday)) {
      continue;
    }

    datesCollection.add(visibleDate);
  }

  return datesCollection;
}