I'm using table_calendar package to display a calendar on a page.
I want the user to be able to chose a date from the calendar, but when tapping on a date, the focusedDay won't change, so it always stays on the default focusedDay.
I tried to search the docs, and I can't figure out what is wrong, from the docs it seems like it should work fine.
This is what I have for the CalendarWidget:
TableCalendar(
focusedDay: _focusedDay,
firstDay: DateTime.now(),
lastDay: DateTime.utc(2030, 1, 1),
calendarFormat: CalendarFormat.month,
headerStyle: HeaderStyle(
formatButtonVisible: false,
titleCentered: true,
rightChevronIcon: Icon(
Icons.chevron_right,
size: 16,
color: Colors.grey,
),
leftChevronIcon: Icon(
Icons.chevron_left,
size: 16,
color: Colors.grey,
),
),
onDaySelected: (selectedDay, focusedDay) {
setState(() {
_selectedDay = selectedDay;
_focusedDay = focusedDay;
});
},
),
This is inside a stateful widget, and I have _focusdDay as a variable in that class, which I update.
The TableCalendar is of course inside the build function of that class.