verifyOtp method

Future<PhoneLookupResult?> verifyOtp({
  1. required String verificationId,
  2. required String code,
})
inherited

Step 2: Verify OTP code. Returns a PhoneLookupResult indicating whether this is a login (existing user) or registration (new user).

Implementation

Future<PhoneLookupResult?> verifyOtp({
  required String verificationId,
  required String code,
}) async {
  state = state.copyWith(status: AuthStatus.authenticating, error: null);
  try {
    final result = await _phoneAuthService.verifyOtp(
      verificationId: verificationId,
      code: code,
    );
    state = state.copyWith(status: AuthStatus.unauthenticated);
    return result;
  } on DioException catch (e) {
    _handleError(e);
    return null;
  }
}