sendOtp method
Step 1: Send OTP to the given phone number.
Implementation
Future<OtpData?> sendOtp(String phone) async {
assert(
_config.authMethod == AuthMethod.phone,
'sendOtp is only available when authMethod == AuthMethod.phone',
);
state = state.copyWith(status: AuthStatus.authenticating, error: null);
try {
final data = await _phoneAuthService.sendOtp(phone);
state = state.copyWith(status: AuthStatus.unauthenticated);
return data;
} on DioException catch (e) {
_handleError(e);
return null;
}
}