checkCode static method

Future<Either<UserCredential, dynamic>> checkCode({
  1. required String verificationId,
  2. required String code,
})

Implementation

static Future<Either<UserCredential, dynamic>> checkCode(
    {required String verificationId, required String code}) async {
  try {
    PhoneAuthCredential credential = PhoneAuthProvider.credential(
      verificationId: verificationId,
      smsCode: code,
    );

    final user = await FirebaseAuth.instance.signInWithCredential(credential);
    return left(user);
  } catch (e) {
    return right(e.toString());
  }
}