这是使用Google帐户登录的方法的代码。 包含在其统计数据中,我可以解决此问题的任何想法???
void main() {
runApp(new FriendlychatApp());
}
Future<Null> _ensureLoggedIn() async {
GoogleSignInAccount user = googleSignIn.currentUser;
if (user == null)
user = await googleSignIn.signInSilently();
if (user == null) {
user = await googleSignIn.signIn();
analytics.logLogin();
}
if (await auth.currentUser() == null) {
GoogleSignInAuthentication credentials =
await googleSignIn.currentUser.authentication;
await auth.signInWithGoogle(
idToken: credentials.idToken,
accessToken: credentials.accessToken,
);
}
}
答案 0 :(得分:1)
Future<Null> _ensureLoggedIn() async {
GoogleSignInAccount user = await googleSignIn.currentUser;
if (user == null)
user = await googleSignIn.signInSilently();
if (user == null) {
user = await googleSignIn.signIn();
analytics.logLogin();
}
var response = await auth.currentUser();
if (response.uid == null) {
GoogleSignInAuthentication credentials =
await googleSignIn.currentUser.authentication;
await auth.signInWithGoogle(
idToken: credentials.idToken,
accessToken: credentials.accessToken,
);
}
}
答案 1 :(得分:0)
我认为您还需要等待下面提到的这一行。
GoogleSignInAccount user = googleSignIn.currentUser;
所以你应该实际使用。
GoogleSignInAccount user = await googleSignIn.currentUser;
让我知道这是否有帮助,
非常感谢, 鳅。