【问题标题】:How to get multiple days events on table_calendar如何在 table_calendar 上获取多天事件
【发布时间】:2019-12-27 19:18:45
【问题描述】:

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

正是从 10 到 13 的周期。

如果 table_calendar 不能做到这一点,有人可以指点我正确的小部件吗?

【问题讨论】:

    标签: flutter flutter-layout flutter-dependencies


    【解决方案1】:

    我明白了。

    您必须从 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 中添加文本以显示事件名称(暂时不要处理)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-05-22
      • 1970-01-01
      相关资源
      最近更新 更多