signingWithPhoneSendCode method

Future<void> signingWithPhoneSendCode({
  1. required String phoneNumber,
  2. required dynamic codeSent(
    1. String?,
    2. int?
    ),
  3. required dynamic callback(),
  4. required dynamic callbackError(),
})

Implementation

Future<void> signingWithPhoneSendCode(
    {required String phoneNumber,
    required Function(String?, int?) codeSent,
    required Function() callback,
    required Function() callbackError}) async {
  _resetState();
  if (!ExaAuthUtils.validateMobile(
      phoneNumber.replaceAll(RegExp(r'\D'), ''))) {
    currentError.value = AuthFailure(
        type: FailureType.invalidPhone, sigInType: SigInType.phone);
    _stopLoad();
    callbackError.call();
    return;
  }

  await signInWithPhoneUseCase.call(
      phoneNumber: '+55${phoneNumber.replaceAll(RegExp(r'\D'), '')}',
      verificationCompleted: (r) {
        _stopLoad();
        //todo successSignIn
        callback.call();
      },
      verificationFail: (l) {
        _stopLoad();
        currentError.value = l;
        callbackError.call();
      },
      codeSent: (verificationToken, code) {
        _stopLoad();
        codeSent.call(verificationToken, code);
      });
}