首页 > 解决方案 > 如何在 SfCalendar 的议程中显示时间?议程只显示主题而不是开始和结束时间

问题描述

如何在议程中显示开始和结束时间?这是我的输出图片供参考。https://i.stack.imgur.com/cfk9t.png。我需要使用什么方法来显示议程中主题的时间。这是 sf 日历中的代码。

Column(
    children: [
      Expanded(
        // flex: 2,
        child: Container(
          child: isLoading
              ? CircularProgressIndicator()
              : SfCalendar(
                  view: CalendarView.month,
                  initialSelectedDate: DateTime.now(),
                  dataSource: TaskDataSource(taskContent),
                  monthViewSettings: MonthViewSettings(
                      showAgenda: true,
                      agendaItemHeight: 40,
                      showTrailingAndLeadingDates: false),
                ),
        ),
      ),
    ],
  ),

这是约会映射的代码。

    class TaskDataSource extends CalendarDataSource {
  TaskDataSource(List<Task> source) {
    appointments = source;
  }

  @override
  DateTime getStartTime(int index) {
    return appointments![index].dateSched;
  }

  @override
  DateTime getEndTime(int index) {
    return appointments![index].dateSched.add(const Duration(hours: 1));
  }

  @override
  bool isAllDay(int index) {
    return true;
  }

  @override
  String getSubject(int index) {
    return appointments![index].title;
  }

  @override
  Color getColor(int index) {
    return Colors.blue;
  }

  @override
  String getNotes(int index) {
    return appointments![index].description;
  }
}

标签: flutter

解决方案


@override
  bool isAllDay(int index) {
    return false;
  }

只需将 isAllday 更改为 false 以在议程中显示开始和结束时间。它对我有用


推荐阅读