-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Description
Use case
Currently, the CupertinoDatePicker widget displays all calendar days by default, allowing users to select any date presented.
While developers can implement logic on the application side to validate or filter selected dates, there's no native mechanism within the widget itself to disable or block specific dates from being presented as selectable options to the user.
This limitation presents a challenge for common application scenarios where users should only be able to interact with a predefined subset of dates. For instance, an appointment booking application needs to guide users to available slots, such as only weekdays or specific dates not marked as holidays or fully booked.
Without native support for disabling dates, developers must display all days, potentially leading to a poor user experience, or implement complex, error-prone filtering logic on the application side to prevent selection of unavailable dates.
Proposal
To address this, I propose introducing a new parameter, weekType, to the CupertinoDatePicker widget.
This parameter would offer a declarative way to control the set of selectable days displayed in the picker, with options such as WeekType.workDays (Monday-Friday), WeekType.weekends (Saturday-Sunday), WeekType.fullWeek (all days), or WeekType.custom. For the WeekType.custom option, developers would provide a List representing the DateTime.weekday values that should be visible and selectable.