getVisibleDates function

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

  final int nonWorkingDaysCount =
      nonWorkingDays == null ? 0 : nonWorkingDays.length;
  final dynamic currentDate = getFirstDayOfWeekDate(
      visibleDatesCount + nonWorkingDaysCount, date, firstDayOfWeek);

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

    datesCollection.add(visibleDate);
  }

  return datesCollection;
}