【问题标题】:How to get AuthResult in flutter Firebase UI to find additionalUserInfo如何在颤动的 Firebase UI 中获取 AuthResult 以查找 AdditionalUserInfo
【发布时间】:2020-04-18 18:01:46
【问题描述】:

我是 Flutter 的新手,使用 sample code 进行登录,我得到了用户,但我需要确定用户以前是否使用过该应用程序(然后卸载)或在新设备上使用过。我看到另一个question 得到如下所示的AuthResult,

AuthResult authResult = await _auth.signInWithCredential(credential);
  if (authResult.additionalUserInfo.isNewUser) {
    //User logging in for the first time
    // Redirect user to tutorial 
  }
  else {
    //User has already logged in before.
    //Show user profile
  }

但是SignInScreen,不返回authResult

SignInScreen(
        title: "Demo",
        header: new Padding(
          padding: const EdgeInsets.symmetric(vertical: 16.0),
          child: new Padding(
            padding: const EdgeInsets.all(16.0),
            child: new Text("Demo"),
          ),
        ),
        showBar: true,
        // horizontalPadding: 8,
        bottomPadding: 5,
        avoidBottomInset: true,
        color: Color(0xFF363636),
        providers: [
          ProvidersTypes.google,
          ProvidersTypes.phone,
          ProvidersTypes.facebook,
        //  ProvidersTypes.twitter,
        //  ProvidersTypes.email
        ],
        twitterConsumerKey: "",
        twitterConsumerSecret: "", horizontalPadding: 12,
      )

【问题讨论】:

    标签: authentication flutter firebase-authentication


    【解决方案1】:

    从查看code 来看,您使用的firebase-ui-flutter 库似乎不会将用户从活动登录操作(对signInWith... 的调用)中公开。

    您要么必须更新库以公开功能、编写自己的登录 UI,要么找到其他处理得更好的库。你也可以file a bug on the repo,但是在过去的两年里很少有人维护它。有一个fork 似乎更新更多,但code 也不会公开主动登录的结果。

    【讨论】:

    • 谢谢,Flutter 中是否有 3rd 方库和原始(即 Google 的官方)库的概念,是否有任何原始库可以完成登录/注册任务或您可以指出的任何示例到?
    猜你喜欢
    • 2020-06-01
    • 2021-08-11
    • 2021-03-21
    • 2022-10-06
    • 1970-01-01
    • 1970-01-01
    • 2021-02-16
    • 2019-09-21
    • 1970-01-01
    相关资源
    最近更新 更多