table_calendar icon indicating copy to clipboard operation
table_calendar copied to clipboard

startingDayOfWeek by default is wrong

Open SergeiLabutin opened this issue 3 years ago • 3 comments

Hi I'm new to flutter and dart =)

I am writing a multilingual application. Switching the locale to ru_RU, the default Calendar doesn't look right.

startDayOfWeek: StartingDayOfWeek.values [MaterialLocalizations.of(context).firstDayOfWeekIndex],

This line works fine. But maybe you can maintain the default behavior using locale data?

Thank.

SergeiLabutin avatar Mar 17 '21 15:03 SergeiLabutin

Hi,

Yes, the default config just assumes that Sunday is the starting day of the week, with an option to provide a custom starting day, as well as custom locale. Linking it to app's config sounds like a good idea (although it can be done manually) - there are some minor hoops that need to be taken care of, but I might go for it.

aleksanderwozniak avatar Mar 18 '21 18:03 aleksanderwozniak

@aleksanderwozniak if you pass StartingDayOfWeek.sunday to widget, this function will add +1 and first day will not be sunday as you would expect int getWeekdayNumber(StartingDayOfWeek weekday) { return StartingDayOfWeek.values.indexOf(weekday) + 1; }

dmitdu avatar Jul 20 '21 15:07 dmitdu

@dmitdu Can you check with provided examples? Basic example has default config and should start on Sunday; events example uses StartingDayOfWeek.monday and should start on Monday:

https://github.com/aleksanderwozniak/table_calendar/blob/9f523a6df34776f0e479cda8b535e2565af994a8/example/lib/pages/events_example.dart#L103

getWeekdayNumber returns 1 for Monday and 7 for Sunday by design.

aleksanderwozniak avatar Jul 21 '21 09:07 aleksanderwozniak