admin管理员组文章数量:1022752
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
},
),
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
},
),
本文标签: tablecalendar not showing custom widget for current date in flutterStack Overflow
版权声明:本文标题:tablecalendar not showing custom widget for current date in flutter - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745518458a2154198.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论