How can I show the time in the agenda in SfCalendar? The Agenda only shows the subject not the start and end time

Viewed 223

How to show the start and end time in agenda? Here's the picture of my output for the reference. https://i.stack.imgur.com/cfk9t.png. What method do I need to use in order to show the time with the subject in the agenda. Here's the code in sf calendar.

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),
                ),
        ),
      ),
    ],
  ),

Here's the code for the mapping of appointments.

    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;
  }
}
1 Answers
@override
  bool isAllDay(int index) {
    return false;
  }

just change the isAllday into false to show the start and end time in the agenda. It works on me

Related