Skip to content

Refactor RecurrenceSettings.weekdays to use List<WeekDays> instead of List<int> #509

@PRBaraiya

Description

@PRBaraiya

To improve clarity and reduce ambiguity around weekday handling, we propose the following changes:

  1. 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.

  1. Expose a DateTime extension for WeekDays

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestpriority:1Bug/Enhancement with highest priority.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions