首页 > 解决方案 > 如何在 table_calendar 上获取多天事件

问题描述

如何设置我的 table_calendar 参数以使事件显示如下图所示: 在此处输入图像描述

正是从 10 到 13 的时期。

如果 table_calendar 无法做到这一点,有人可以将我指向正确的小部件吗?

标签: flutterflutter-layoutflutter-dependencies

解决方案


我得到它。

从 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,
      ),
    );
}

您可以在里面添加 TextContainer以显示事件名称(暂时不要处理它)


推荐阅读