Flutter Google Calendar Api列表活动 [英] Flutter Google Calendar Api list Events
问题描述
Flutter,Google Calendar API v3 https://pub.dartlang.org/packages/googleapis
Flutter, Google Calendar API v3 https://pub.dartlang.org/packages/googleapis
作品:
Future<List<Event>> getEvents() =>
calendarApi.events.list("primary",
)
.then((Events events){
return events.items;
}).catchError((e){
print("error encountered");
print("${e.toString()}");
});
不起作用:
DateTime start = new DateTime.now().subtract(new Duration(days: 10));
DateTime end = new DateTime.now().add(new Duration(days: 10));
..
Future<List<Event>> getEvents() =>
calendarApi.events.list("primary",
timeMin: start,
timeMax: end,
)
.then((Events events){
return events.items;
}).catchError((e){
print("error encountered");
print("${e.toString()}");
});
推荐答案
根据Google日历API,timeMin和timeMax值必须遵循RFC3339日期标准.
According to the Google calendar API the timeMin and timeMax values must follow the RFC3339 date standard.
内部,日历在您传入的DateTimes上应用.toIso8601String()
.但是,这不能使它们成为有效的RFC3339日期.
Internally the calendar applies .toIso8601String()
on the DateTimes you pass in. However that does not make them valid RFC3339 dates.
在传入它们之前调用.toUtc()
将使它们成为有效的RFC3339.您可以在 DartPad Togheter中使用 Google的Api资源管理器,您将看到不同的响应.
Calling .toUtc()
before passing them in will make them a valid RFC3339. You can try it in DartPad togheter with Googles Api explorer and you will see the different responses.
也许有更多方法可以使DateTime符合RFC3339,但这应该使您至少指出错误.
There is probably more ways to make DateTime RFC3339 compliant but this should point you to the error atleast.
这篇关于Flutter Google Calendar Api列表活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!