Bdaya-Dev / flutter_gantt_chart

Flutter Gantt chart UI library
BSD 3-Clause "New" or "Revised" License
11 stars 10 forks source link

Error if holiday falls on a Monday #14

Open donsafar opened 3 months ago

donsafar commented 3 months ago

Here is the error message - _AssertionError ('package:gantt_chart/src/gantt_view.dart': Failed assertion: line 44 pos 11: '!weekEnds.contains(startOfTheWeek)': startOfTheWeek must be a work day)

Today is Labor Day which is a holiday and falls on a Monday. Getting the error above. Is there a fix for this?

ahmednfwela commented 3 months ago

hi @donsafar , you can try setting weekEnds parameter to NOT include monday https://github.com/Bdaya-Dev/flutter_gantt_chart/blob/5ea903d8378f67b620f2b609d96a3675949853a2/lib/src/gantt_view.dart#L32

and startOfTheWeek to be monday

https://github.com/Bdaya-Dev/flutter_gantt_chart/blob/5ea903d8378f67b620f2b609d96a3675949853a2/lib/src/gantt_view.dart#L37

To mark a special holiday, return it in isExtraHoliday

donsafar commented 3 months ago

hi @donsafar , you can try setting weekEnds parameter to NOT include monday

https://github.com/Bdaya-Dev/flutter_gantt_chart/blob/5ea903d8378f67b620f2b609d96a3675949853a2/lib/src/gantt_view.dart#L32

and startOfTheWeek to be monday

https://github.com/Bdaya-Dev/flutter_gantt_chart/blob/5ea903d8378f67b620f2b609d96a3675949853a2/lib/src/gantt_view.dart#L37

To mark a special holiday, return it in isExtraHoliday

Actually, it should check if the date is a holiday then add 1 day to the date until you reach the next work day. eg. if the date is a Friday and it is a holiday, it would set the date to the next workday that is not a weekend date or a holiday

ahmednfwela commented 3 months ago

surely I can do some calculation to find the first workday, but it's better to make the API consumer choose this explicitly