Flutter Google Calendar Api列表活动 [英] Flutter Google Calendar Api list Events

查看:98
本文介绍了Flutter Google Calendar Api列表活动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆