AuthClient 不是一个类型,因此它不能用作类型参数 - Dart 包googleapis_auth



我不知道为什么我得到上面的错误。我的软件包已正确安装。这不是我的linter的问题,因为这个问题也会阻止编译。我使用版本1.3.1的googleapis_auth。在撰写本文时,这是最新的。另外,提取代码只是从pub.dev文档中复制粘贴的。下面是我的代码。

import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:http/http.dart' as http;
import 'package:googleapis_auth/auth_io.dart' as auth;
class GmailButton extends StatelessWidget {
GmailButton({Key? key}) : super(key: key);
Widget build(BuildContext context){
return(
Container()
);
}
// Obtain an access token
// Use service account credentials to get an authenticated and auto refreshing client.
Future<AuthClient> obtainAuthenticatedClient() async {
final accountCredentials = ServiceAccountCredentials.fromJson({
"private_key_id": "<please fill in>",
"private_key": "<please fill in>",
"client_email": "<please fill in>@developer.gserviceaccount.com",
"client_id": "<please fill in>.apps.googleusercontent.com",
"type": "service_account"
});
var scopes = ['https://mail.google.com'];
AuthClient client = await clientViaServiceAccount(accountCredentials, scopes);
return client; // Remember to close the client when you are finished with it.
}
// Send the email
}

我应该写auth.AuthClient,因为我将导入命名为auth。我没有提到的Googleapis_auth包成员的其他成员也是如此。

最新更新