在Flutter Firebase auth中注销不同类型的帐户的按钮
我有一个flutter应用程序,其中包含多个选项(电子邮件和密码,Google帐户,电话号码)。用户登录应用程序后,他将有一个抽屉。 该抽屉里有一个签名按钮,当用户按下时应该签名并将其发送回注册页面。所以我一直在使用firebase auth的登录实例 await firebaseauth.instance.signout();
,但是由于我在选项中添加了Google签名,因此我开始面临一个问题,即Google签名,我会nee dto do do do连接用户first 等待googlelesignin .disconnect();
因此,我将这一行添加到登录功能中,以至于这样:
Future<void> SignOut() async {
await googleSignIn.disconnect();
await FirebaseAuth.instance.signOut();
Navigator.pushAndRemoveUntil(
context,
MaterialPageRoute(
builder: (BuildContext context) => AuthPage(),
),
(route) => false,
);}
当用户使用Google登录时,此按钮可以正常工作,但是如果他使用不同的方法登录,则会出现错误:
未经治疗的异常:platformException(状态,无法断开连接。,null,null)
如何使用一个按钮处理不同类型的用户签名?
I have a flutter app with multiple sign in options (Email and password, Google account, phone number). Once the user sign in to the application, he will then have a drawer.
There is a Sign out button inside this drawer which should sign the user out when he press it and send him back to the signup page. So I have been using the sign out instance from firebase authawait FirebaseAuth.instance.signOut();
But since I added the google sign in options I started facing a problem which is that for google sign out, I nee dto disconnect the user first await googleSignIn.disconnect();
So I added this line to the sign out function to be like this:
Future<void> SignOut() async {
await googleSignIn.disconnect();
await FirebaseAuth.instance.signOut();
Navigator.pushAndRemoveUntil(
context,
MaterialPageRoute(
builder: (BuildContext context) => AuthPage(),
),
(route) => false,
);}
This button works fine when the user sign in with google but if he signs in with different method then an error will be thrown:
Unhandled Exception: PlatformException(status, Failed to disconnect., null, null)
How can I handle different type of users signout with one button?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)