submitOTP method

Future<bool> submitOTP({
  1. bool autoFill = false,
})

Implementation

Future<bool> submitOTP({bool autoFill = false}) async {
  if (uiState == OTPLoginUIState.submittingOTP) {
    return false;
  }
  uiState = OTPLoginUIState.submittingOTP;
  otpSubmitStatusMessage = '';
  notifyListeners();
  try {
    final sessionId = await doSubmitOTP(autoFill);
    await authDataStore.setSessionId(sessionId);
    profileDataStore.setPhone(phoneNumber);
    uiState = OTPLoginUIState.loggedIn;
    notifyListeners();
    return true;
  } on ValueError catch (error) {
    otpSubmitStatusMessage = error.message;
  } on SocketException catch (_) {
    otpSubmitStatusMessage = socketExceptionDefaultMessage;
  } catch (_) {
    otpSubmitStatusMessage = "An error occurred, we're looking into it";

    if (kDebugMode) {
      rethrow;
    }
  }
  uiState = OTPLoginUIState.failedToSubmitOTP;
  notifyListeners();
  return false;
}