onCredentialReceived method

  1. @override
Future<void> onCredentialReceived(
  1. AuthCredential credential
)

Implementation

@override
Future<void> onCredentialReceived(AuthCredential credential) async {
  try {
    if (action == AuthAction.signUp) {
      value = SigningUp();

      final userCredential = await auth.createUserWithEmailAndPassword(
        email: (credential as EmailAuthCredential).email,
        password: credential.password!,
      );

      value = UserCreated(userCredential);

      action = AuthAction.signIn;
      await super.onCredentialReceived(credential);
    } else {
      await super.onCredentialReceived(credential);
    }
  } on Exception catch (e) {
    value = AuthFailed(e);
  }
}