resendOTP method

Future<void> resendOTP(
  1. dynamic phoneNo
)

Implementation

Future<void> resendOTP(phoneNo) async {
  try {
    resultPin.value = '';
    resultPin.refresh();
    cancelTimer();
    startTimer();
    loadingDialog();
    await FirebaseAuth.instance.verifyPhoneNumber(
      phoneNumber: phoneNo,
      forceResendingToken: myResendToken,
      verificationCompleted: (PhoneAuthCredential credential) async {},
      verificationFailed: (FirebaseAuthException e) {
        closeDialog();
        if (e.code == 'invalid-phone-number') {
          if (kDebugMode) {
            print('The provided phone number is not valid.');
          }
          CustomFlashWidget.showFlashMessage(
              title: "Phone number not correct",
              message:
                  "Please enter the phone number correctly with select the country as well");
          Get.back();
        } else {
          print(e.message);
        }
      },
      codeSent: (String verificationId, int? resendToken) async {
        closeDialog();
        myResendToken = resendToken;
        myVerificationID = verificationId;
        CustomFlashWidget.showFlashMessage(
            title: "Success",
            message: "OTP has been resent successfully!",
            type: FlashType.success);
      },
      codeAutoRetrievalTimeout: (String verificationId) {
        closeDialog();
        if (kDebugMode) {
          print("print called from codeAutoRetrievalTimeout ");
        }
      },
    );
  } catch (e) {
    if (kDebugMode) {
      print("error is here $e");
    }
    closeDialog();
    CustomFlashWidget.showFlashMessage(title: "Error", message: e.toString());
  }
}