如何在 table_calendar 上获取多天活动

How to get multiple days events on table_calendar

如何设置我的 table_calendar 参数以使事件显示如下图所示:

正好是从 10 到 13 的时间段。

如果 table_calendar 无法执行此操作,有人可以为我指出正确的小部件吗?

我明白了。

从 table_calendar 开始,您必须为 CalendarBuilders 添加构建器。

 builders: CalendarBuilders(
     markersBuilder: (context, date, events, holidays) {
         if (events.isNotEmpty) {
             children.add(
                 Positioned(
                     right: 1,
                     top: 1,
                     child: _buildEventsMarker(date, events),
                 ),
             );
         }
     }
 );

对于这个构建器,为事件日期数组设置一个孩子。

还有你_buildEventsMarker

Widget _buildEventsMarker() {
   return Container(
      width: 80.0,
      height: 20.0,

      decoration: BoxDecoration(
         color: Colors.blue,
         shape:  BoxShape.rectangle ,
         borderRadius: null,
      ),
    );
}

可以在Container里面添加Text来显示事件名称(暂不处理)