getNoOfSpaceRequiredBeforeFirstValidDate static method
This method returns the number of spaces required before first valid based of the hidden weekdays. For example, if the first valid date falls on a Tuesday, that means that the weekday "monday" is hidden, which makes the first valid date index "1"
Implementation
static int getNoOfSpaceRequiredBeforeFirstValidDate(
List<int> weekdaysToHide,
int weekdayValueForFirstValidDay, [
bool isSundayFirstDayOfWeek = false,
]) {
final mondayWeekDayList = [1, 2, 3, 4, 5, 6, 7];
final sundayWeekDayList = [7, 1, 2, 3, 4, 5, 6];
mondayWeekDayList.removeWhere(
(weekday) => weekdaysToHide.contains(weekday),
);
sundayWeekDayList.removeWhere(
(weekday) => weekdaysToHide.contains(weekday),
);
return isSundayFirstDayOfWeek
? sundayWeekDayList.indexOf(weekdayValueForFirstValidDay)
: mondayWeekDayList.indexOf(weekdayValueForFirstValidDay);
}