-
Notifications
You must be signed in to change notification settings - Fork 313
Refactor RecurrenceSettings.weekdays to use List<WeekDays> instead of List<int> #509
Description
To improve clarity and reduce ambiguity around weekday handling, we propose the following changes:
- Refactor
RecurrenceSettings.weekdays
Currently, RecurrenceSettings accepts weekdays as a List<int>, which requires users to manually map Dart’s DateTime.weekday values to the package’s internal weekday representation. This can be confusing and may lead to subtle bugs.
We propose updating this API to accept List<WeekDays>, where WeekDays is the enum defined by this package. This will make the API more explicit, easier to understand, and safer to use. Although this is a breaking change, it will surface compile-time errors during upgrades, prompting users to make the necessary updates explicitly and avoiding silent runtime issues.
- Expose a
DateTimeextension forWeekDays
To make the migration and general usage easier, we will expose an extension on DateTime that allows users to directly obtain the corresponding WeekDays value from a DateTime instance. This will remove the need for manual mapping and provide a more ergonomic and consistent developer experience.
Overall, these changes aim to improve API correctness, usability, and long-term maintainability while minimizing the risk of unexpected behavior.