Syncfusion 日历未显示第一个时间间隔

问题描述 投票:0回答:1

我正在使用 syncfusion_flutter_calendar,在日视图中我显示的时间范围是上午 7 点到下午 5 点。我的问题是第一次(7:00AM)没有显示,而是我看到的是7:30AM

这是我的代码:

SfCalendar(
  //dataSource: MeetingDataSource(_getDataSource()),
  allowedViews: const [CalendarView.day],
  timeSlotViewSettings: const TimeSlotViewSettings(
    startHour: 7.0,
    endHour: 17.0,
    timeInterval: Duration(minutes: 30),
    timeFormat: 'h:mm a',
  ),
)

我尝试将

startHour
缩短 30 分钟,但视觉效果并不完全是我想要的(顶部多了一行),此外用户可以创建从早上 6:30 开始的约会。

任何有关如何首次展示的帮助,我们将不胜感激。

flutter dart syncfusion syncfusion-calendar
1个回答
0
投票

没有直接支持来实现您在视图中显示开始时间的要求。但是,您可以借助 SfCalendar 中的 time specialRegions 属性来实现此目的。这里,我们在timeSlotViewSettings中将startHour设置为6,并将6到7的时间区域添加为特殊区域,并借助enablePointerInteraction禁用该特殊区域的交互。

我分享了下面的屏幕截图和代码片段供您参考。我们希望它能帮助您实现您的要求。

代码片段:

DateTime initialDate = DateTime.fromMillisecondsSinceEpoch(1);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      home: Scaffold(
        body: SafeArea(
            child: SfCalendar(
          allowedViews: const [CalendarView.day],
          specialRegions: [
            TimeRegion(
              startTime: DateTime(
                  initialDate.year, initialDate.month, initialDate.day, 06, 00),
              endTime: DateTime(
                  initialDate.year, initialDate.month, initialDate.day, 07, 00),
              recurrenceRule: 'FREQ=DAILY;INTERVAL=1',
              enablePointerInteraction: false,
              color: Colors.grey.withOpacity(0.2),
            )
          ],
          timeSlotViewSettings: const TimeSlotViewSettings(
            startHour: 6.0,
            endHour: 17.0,
            timeInterval: Duration(minutes: 30),
            timeFormat: 'h:mm ',
          ),
        )),
      ),
    );
  }
© www.soinside.com 2019 - 2024. All rights reserved.