Flutter Phone身份验证错误原始示例 [英] Flutter Phone authentication error original example
问题描述
亲爱的
我正在开发电话认证的此示例(原始示例): https://github.com/flutter/plugins/tree/master/包/firebase_auth/example
I am developing this example (the original) of phone authentication: https://github.com/flutter/plugins/tree/master/packages/firebase_auth/example
当然,我添加了.json和正确的依赖项(我认为,因为firebase的其他补充版本工作正常).
Of course, I added the .json and correct dependencies (I think, because other complements of firebase works fine).
但是,我得到了这段代码:
But, I get this part of code:
Future<String> _testSignInWithGoogle() async {
final GoogleSignInAccount googleUser = await _googleSignIn.signIn();
final GoogleSignInAuthentication googleAuth =
await googleUser.authentication;
final AuthCredential credential = GoogleAuthProvider.getCredential(
accessToken: googleAuth.accessToken,
idToken: googleAuth.idToken,
);
final FirebaseUser user = await _auth.signInWithCredential(credential);
assert(user.email != null);
assert(user.displayName != null);
assert(!user.isAnonymous);
assert(await user.getIdToken() != null);
final FirebaseUser currentUser = await _auth.currentUser();
assert(user.uid == currentUser.uid);
return 'signInWithGoogle succeeded: $user';
}
我有这些错误:
- 未定义的AuthCredential
- 未定义名称GoogleAuthProvider
- 未为类FirebaseAuth定义方法signInWithCredential
能帮我吗?如果是原始示例,我不理解这些错误.
Can you help me please? I don't understand these error if it is the original example.
谢谢!
推荐答案
该示例似乎已过时,可以省略AuthCredential
和GoogleAuthProvider
.
It looks like that sample is outdated , you can omit AuthCredential
and GoogleAuthProvider
.
Future<String> _testSignInWithGoogle() async {
final GoogleSignInAccount googleUser = await _googleSignIn.signIn();
final GoogleSignInAuthentication googleAuth =
await googleUser.authentication;
final FirebaseUser user =
await FirebaseAuth.instance.signInWithGoogle(
accessToken: googleAuth.accessToken,
idToken: googleAuth.idToken,
);
assert(user.email != null);
assert(user.displayName != null);
assert(!user.isAnonymous);
assert(await user.getIdToken() != null);
final FirebaseUser currentUser = await _auth.currentUser();
assert(user.uid == currentUser.uid);
return 'signInWithGoogle succeeded: $user';
}
这篇关于Flutter Phone身份验证错误原始示例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!