onRequest method
Called when the request is about to be sent.
Implementation
@override
void onRequest(RequestOptions options, RequestInterceptorHandler handler) {
if (_config.logRequests) {
_logger.debug(
'DioInterceptor: → ${options.method} ${options.uri}',
);
}
// If offline and queueing is enabled, reject early so the error handler
// can enqueue.
if (!_monitor.isOnline && _config.queueWhenOffline) {
handler.reject(
DioException(
requestOptions: options,
type: DioExceptionType.connectionError,
message: 'Device is offline — request will be queued',
),
);
return;
}
handler.next(options);
}