resend method
Requests a fresh code. channel null repeats the channel the current
code went out on (what the widget's "Resend OTP" button does); the
expired screen passes the channel the user picked.
Implementation
Future<AuthyoResult> resend(AuthwayEnum? channel) async {
errorMessage = null;
infoMessage = null;
otpError = null;
_setLoading(true);
final res = await _service.requestOtp(
to: to,
authWay: channel ?? lastChannel ?? (isEmail ? AuthwayEnum.email : null),
otpLength: otpLength,
expiry: resendTimerSeconds > 0 ? resendTimerSeconds : null,
);
if (_disposed) return res;
if (res.error != null) {
errorMessage = res.error!.message;
} else {
_adoptSendResult(res);
if (maskId == null) {
errorMessage = 'Error in sending OTP. Please check entered details.';
} else {
infoMessage = 'OTP sent successfully';
otp = '';
_restartTimer();
_restartResendCooldown();
}
}
_setLoading(false);
return res;
}