onCredentialReceived method

void onCredentialReceived(
  1. K credential,
  2. AuthAction action
)

A method that is called when the user has successfully completed the authentication process and decides what to do with the obtained credential.

linkWithCredential and respectful lifecycle hooks are called if action is AuthAction.link.

signInWithCredential and respectful lifecycle hooks are called if action is AuthAction.signIn.

FirebaseAuth.createUserWithEmailAndPassword and respectful lifecycle hooks are called if action is AuthAction.signUp.

Implementation

void onCredentialReceived(K credential, AuthAction action) {
  switch (action) {
    case AuthAction.link:
      linkWithCredential(credential);
      break;
    case AuthAction.signIn:
    // Only email provider has a different action for sign in and sign up
    // and implements it's own sign up logic.
    case AuthAction.signUp:
      if (shouldUpgradeAnonymous) {
        linkWithCredential(credential);
        break;
      }

      signInWithCredential(credential);
      break;
    case AuthAction.none:
      authListener.onCredentialReceived(credential);
      break;
  }
}