resend method

Future<void> resend()

Re-send the OTP challenge for the previously-submitted email. No-op when the resend cooldown has not yet elapsed or when an operation is already in flight. On success the cooldown restarts; on failure the error is stored on error and the cooldown is not touched.

Implementation

Future<void> resend() async {
  if (!canResend || _submittedEmail.isEmpty) {
    return;
  }
  _isLoading = true;
  _error = null;
  _safeNotify();
  try {
    final CrossmintEmailOtpChallenge challenge = await _auth.sendEmailOtp(
      _submittedEmail,
    );
    if (_disposed) {
      return;
    }
    _emailId = challenge.state;
    _startCooldown();
  } on Exception catch (e) {
    if (!_disposed) {
      _error = e.toString();
    }
  } finally {
    if (!_disposed) {
      _isLoading = false;
      _safeNotify();
    }
  }
}