Moh*_*nab 6 android google-authentication flutter
我尝试先使用谷歌登录,我的信息我选择了谷歌帐户,它卡在加载中,没有任何响应,甚至没有任何与之相关的控制台消息,这是我的代码
GoogleSignInAccount _currentUser;
GoogleSignIn _googleSignIn = GoogleSignIn(
scopes: [
'email',
'https://www.googleapis.com/auth/cloud-platform.read-only',
],
);
@override
void initState() {
super.initState();
_googleSignIn.onCurrentUserChanged.listen((GoogleSignInAccount account) {
setState(() {
_currentUser = account;
});
});
_googleSignIn.signInSilently();
}
Future<void> _googlelogin() async {
try {
final GoogleSignInAccount googleSignInAccount =
await _googleSignIn.signIn();
final GoogleSignInAuthentication googleSignInAuthentication =
await googleSignInAccount.authentication;
} catch (error) {
print(error);
}
}
....
RaisedButton(
onPressed: () {
_googlelogin();
},),
),
Run Code Online (Sandbox Code Playgroud)
预览正在发生的事情
com.google.gms:google-services穿上了。build.gradle他们都不为我工作。每次我选择 Gmail 帐户时,它都会无限期地加载,并且控制台中也没有打印任何重要信息。
但这对我有用:
dependencies:
firebase_core: ^1.7.0
firebase_auth: ^3.1.2
googleapis: ^5.0.1
google_sign_in: ^5.1.1
Run Code Online (Sandbox Code Playgroud)
dependencies:
firebase_core: ^1.7.0
firebase_auth: ^3.1.2
googleapis: ^5.0.1
google_sign_in: ^5.1.1
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2694 次 |
| 最近记录: |