I am using TableCalendar for showing all data and i am using customWidget for each date.
its showing my customwidget to all dates except current date. i mean to today's date.
what should i change to my code to show my customwidget for today also.
class CalendarWidget extends StatelessWidget {
final int month;
final int year;
CalendarWidget({Key? key,required this.month,required this.year}) : super(key: key);
@override
Widget build(BuildContext context) {
return TableCalendar(
headerVisible: false,
availableGestures: AvailableGestures.none,
focusedDay: DateTime(year,month,1),
firstDay: DateTime(year,month,1),
lastDay: DateTime(year,month + 1, 0), // This will return last day of current month
startingDayOfWeek: StartingDayOfWeek.monday,
//availableGestures: AvailableGestures.none,
daysOfWeekHeight: 30,
rowHeight: 80,
calendarBuilders: CalendarBuilders(
defaultBuilder: (context, day, focusedDay) {
return CustomWidget();// this is not showing on current date
},
),
);
}
}
I am using TableCalendar for showing all data and i am using customWidget for each date.
its showing my customwidget to all dates except current date. i mean to today's date.
what should i change to my code to show my customwidget for today also.
class CalendarWidget extends StatelessWidget {
final int month;
final int year;
CalendarWidget({Key? key,required this.month,required this.year}) : super(key: key);
@override
Widget build(BuildContext context) {
return TableCalendar(
headerVisible: false,
availableGestures: AvailableGestures.none,
focusedDay: DateTime(year,month,1),
firstDay: DateTime(year,month,1),
lastDay: DateTime(year,month + 1, 0), // This will return last day of current month
startingDayOfWeek: StartingDayOfWeek.monday,
//availableGestures: AvailableGestures.none,
daysOfWeekHeight: 30,
rowHeight: 80,
calendarBuilders: CalendarBuilders(
defaultBuilder: (context, day, focusedDay) {
return CustomWidget();// this is not showing on current date
},
),
);
}
}
Share
Improve this question
edited Nov 28, 2024 at 10:06
Irfan Ganatra
asked Nov 28, 2024 at 9:52
Irfan GanatraIrfan Ganatra
1,4088 silver badges30 bronze badges
1 Answer
Reset to default 1You can use todayBuilder
calendarBuilders: CalendarBuilders(
defaultBuilder: (context, day, focusedDay) {
return CustomWidget();
},
todayBuilder: (context, day, focusedDay) {
return CustomWidget(); // this widget will replace Today's cell
},
),