[英]Display number of events in TableCalendar Flutter
TableCalendar package have an gif example of calendar with number of events for given day in bottom right corner of a day. TableCalendar package在一天的右下角有一个日历的 gif 示例,其中包含给定日期的事件数。
I've been going through their documentation , but haven't been able to find the solution.我一直在浏览他们的文档,但无法找到解决方案。
I've learned that those dots are called markers, and found MarkerBuilder , but I don't know how to implement it in my code.我了解到这些点称为标记,并找到了 MarkerBuilder ,但我不知道如何在我的代码中实现它。
How do I achieve this?我如何实现这一目标?
You can overwrite the markerbuilder function with your own.您可以用自己的标记生成器 function 覆盖。 Something like:
就像是:
TableCalendar(
...
calendarStyle: const CalendarStyle(
markersAlignment: Alignment.bottomRight,
),
calendarBuilders: CalendarBuilders(
markerBuilder: (context, day, events) => events.isNotEmpty
? Container(
width: 24,
height: 24,
alignment: Alignment.center,
decoration: const BoxDecoration(
color: Colors.lightBlue,
),
child: Text(
'${events.length}',
style: const TextStyle(color: Colors.white),
),
)
: null,
)
)
You can put pretty much anything you like there, as its just another widget.你可以把你喜欢的任何东西放在那里,因为它只是另一个小部件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.