首页 > 解决方案 > Flutter 中的 device_calendar 更新缓慢

问题描述

我正在 Flutter 中开发一个调度应用程序,并尝试使用 device_calendar ( https://pub.dev/packages/device_calendar ) 包来获取、更新和创建事件。不幸的是,需要很长时间才能更新事情的进展。我得到这样的日历事件:

 List<Event> calendarEvents = [];
  await Future.forEach(calendars, ((Calendar calendar) async {
    var singleCalendarEventsResult =
        await _deviceCalendarPlugin.retrieveEvents(calendar.id,
            RetrieveEventsParams(startDate: startDate, endDate: endDate));
    List<Event> singleCalendarEvents =
        singleCalendarEventsResult.data as List<Event>;
    calendarEvents.addAll(singleCalendarEvents);
  }));

其中 _deviceCalendarPlugin 是此处声明的当前状态的属性:

late DeviceCalendarPlugin _deviceCalendarPlugin;
EventsListState() {
    _deviceCalendarPlugin = DeviceCalendarPlugin();
}

没有错误,只是在任何新事件或日历更改出现之前大约需要 5 分钟,即使这些更改是在应用程序中进行的(而它们几乎会立即出现在 Google 日历上)。这是使用设备日历的一般限制,还是我这样做的方式有问题?有没有办法触发设备日历的刷新?我正在通过 USB 调试使用我的实际 Pixel 4a android 手机进行调试。

谢谢你的帮助!!

编辑:我现在也尝试使用 manage_calendar_events 包,同样的问题。添加了一个新日历,但 15 分钟后它没有显示在我的日历页面上,即使它显示在设备上的 Google 日历中。

标签: androidfluttercalendarflutter-dependencies

解决方案


推荐阅读