aleksanderwozniak / table_calendar

Highly customizable, feature-packed calendar widget for Flutter
Apache License 2.0
1.83k stars 1k forks source link

Tracking amount of selected days within a given week. #503

Closed sevenfold4 closed 3 years ago

sevenfold4 commented 3 years ago

I am using selected days on table calendar as markings, if i did something on that day or not. I am wondering if I can track the amount of selected days i selected within the given week (From Monday to Sunday) For example, if I select 3 days on that week, I have a variable that reflects, that 3 days were selected, and the counter resets on a new week.

aleksanderwozniak commented 3 years ago

If you follow the multiple selection example, you will find _selectedDays collection there: https://github.com/aleksanderwozniak/table_calendar/blob/129f7b0a01c9d9e6865822cb66ef5e9c61d02a71/example/lib/pages/multi_example.dart#L20

Once you have this collection, you can iterate over it to find elements that match your requirements - in your case a particular week.

sevenfold4 commented 3 years ago

I used the multi example to create a basic habit tracker. Select days where I did the required thing. But I don't understand how this would help me create a timeframe where I can track how many days were selected in this timeframe. Would you happen to have any more examples?

aleksanderwozniak commented 3 years ago

You need to define your time frames manually; the way to do this will depend on your specific design.

For example you can use the focused day - https://github.com/aleksanderwozniak/table_calendar/issues/441#issuecomment-802757620, but you can also use the last selected day to calculate boundaries. It's all up to you.