How to get AuthResult in flutter Firebase UI to find additionalUserInfo

匆匆过客 提交于 2020-01-06 08:05:49

问题


I am new to flutter and using sample code that does signIn, I get the user, but I need to find if the user has previously used the App ( and then uninstalled) or using on a new device. I see another question that gets the AuthResult as shown below,

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
  }

But the SignInScreen, does not return the 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,
      )

回答1:


From looking at the code, it looks like the firebase-ui-flutter library that you're using does not expose the user from the active sign-in operation (calls to signInWith...).

You'll either have to update the library to expose the functionality, write your own sign-in UI, or find another library that handles it better. You could also file a bug on the repo, but it's seen very little maintenance in the past two years. There's a fork that seems more update, but that code also doesn't expose the result from active sign-in.



来源:https://stackoverflow.com/questions/59523235/how-to-get-authresult-in-flutter-firebase-ui-to-find-additionaluserinfo

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!