flutter - 如何在 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;
}
}
解决方案
@override
bool isAllDay(int index) {
return false;
}
只需将 isAllday 更改为 false 以在议程中显示开始和结束时间。它对我有用
推荐阅读
- php - PHP imap_search 在已发送文件夹中不起作用
- git - 使用 VSCode 撤消上次推送
- javascript - 如何在javascript中计算字符串中的原始字符?
- javascript - 如何在 ExtJS 中单击按钮时打开模式
- python - 合并 2 个带有时间戳的 numpy 数组
- html - 创建现代形式,可访问等的最佳实践是什么?特别是标签与占位符之争
- rust - tokio::run() 和发送标记的编译错误
- python - Python 3.5+ 中的 list() 与可迭代解包
- reactjs - ReactJS - 自定义组件启动所有工具提示
- perl - Perl - Mojolicious - 在模板中打印 undef 键