table_calendar
table_calendar copied to clipboard
startingDayOfWeek by default is wrong
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.
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 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
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.