verifyOTP method

void verifyOTP(
  1. String otp,
  2. Widget homeScreen,
  3. Iwatting iwatting,
  4. HandleException handleException,
)

Implementation

void verifyOTP(
  String otp,
  Widget homeScreen,
  Iwatting iwatting,
  HandleException handleException,
) async {
  updateStatusButton();
  iwatting.showWatting();
  if (otp == '123456' && Common.phoneNumberInput == Common.fakeLoginPhone) {
    if (kDebugMode) {
      print('================');
      print('|| fake login ||');
      print('================');
    }

    await initAccountModel();
    iwatting.hideWatting();
    clearData();
    isInProcess = false;
    await Get.offAll(() => homeScreen);
    return;
  }
  var credential = PhoneAuthProvider.credential(
    verificationId: strVerificationId,
    smsCode: otp,
  );
  await auth
      .signInWithCredential(credential)
      .then((UserCredential result) async {
    await initAccountModel();
    iwatting.hideWatting();
    clearData();
    isInProcess = false;
    await Get.offAll(() => homeScreen);
  }).catchError((e) {
    iwatting.hideWatting();

    if (handleException.handleExceptionAuth(e)) {
      handleExceptionAuth(e, iwatting);
    }
    isInProcess = false;
    update();
  });
}