dooboolab-community / flutter_calendar_carousel

Calendar widget for flutter that is swipeable horizontally. This widget can help you build your own calendar widget highly customizable.
MIT License
837 stars 307 forks source link

Multiple days selection using addRange method #285

Closed takumade closed 3 years ago

takumade commented 3 years ago

Hi This is more of a cosmetic feature

I ve added addRange method which allows you to select multiple days without calling the add method multiple times.

So Instead of doing this to select multiple days programmatically:

MultipleMarkedDates multipleMarkedDates = new MultipleMarkedDates(markedDates: []);
multipleMarkedDates.add(new MarkedDate(date: DateTime(2021, 7, 12), color: Colors.purple));
multipleMarkedDates.add(new MarkedDate(date: DateTime(2021, 7, 13), color: Colors.purple));
multipleMarkedDates.add(new MarkedDate(date: DateTime(2021, 7, 14), color: Colors.purple));

They can now do this instead:

MultipleMarkedDates multipleMarkedDates = new MultipleMarkedDates(markedDates: []);
multipleMarkedDates.addRange(new MarkedDate(date: DateTime(2021, 8, 4), color: Colors.purple), plus: 5);

This will select the following days

2021 / 8 / 4
2021 / 8 / 5
2021 / 8 / 6
2021 / 8 / 7
2021 / 8 / 8
2021 / 8 / 9

addRange Method

addRange methods accepts the following arguments

Argument Type Description Required Default
date MarkedDate Specify which date will be selected Yes
plus int The number of days to select after date No 0
minus int The number of days to select before date No 0

FAQ 1. Did you remove the add method? No

2. What if a user leaves plus and minus arguments? It will just select date only