gpt4 book ai didi

dart - 安装google api日历时出现flutter dart错误

转载 作者:IT王子 更新时间:2023-10-29 07:23:16 29 4
gpt4 key购买 nike

我将显示来自 Google 日历的事件列表。我已经按照以下链接中的示例进行操作:How to use Google API in flutter?

我的脚本如下:

将 'package:http/http.dart' 导入为 http;

假设我已经登录。

GoogleSignIn _googleSignIn = GoogleSignIn(
scopes: <String>[
'email',
'https://www.googleapis.com/auth/contacts.readonly',
'https://www.googleapis.com/auth/calendar'
],
);'
class GoogleHttpClient extends http.BaseClient {
Map<String, String> _headers;

GoogleHttpClient(this._headers) : super();

@override
Future<http.StreamedResponse> send(http.BaseRequest request) =>
super.send(request..headers.addAll(_headers)); //have error 'the method 'send' is always abstract in the supertype'

@override
Future<http.Response> head(Object url, {Map<String, String> headers}) =>
super.head(url, headers: headers..addAll(_headers));
}
void getCalendarEvents() async {
final authHeaders = _googleSignIn.currentUser.authHeaders;
final httpClient = new GoogleHttpClient(authHeaders); //have error "The argument type 'Future<Map<String, String>>' can't be assigned to the parameter type 'Map<String, String>'"
var calendar = new Calendar.CalendarApi(new http.Client());
var calEvents = calendar.events.list("primary");
calEvents.then((Calendar.Events events) {
events.items.forEach((Calendar.Event event) {print(event.summary);});
});
}

由于错误,上述脚本无法运行。

the method 'send' is always abstract in the supertype

谁能帮帮我?

最佳答案

如果您的代码基于 How to use Google API in flutter?你会看到我有一个 @override Future<StreamedResponse> send(...)在我的代码中。

GoogleHttpClient延伸abstract class IOClient缺少 send 的实现,所以具体的子类需要实现它。

这就是错误消息的内容。

关于dart - 安装google api日历时出现flutter dart错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54454781/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com