onRequest method

  1. @override
void onRequest(
  1. RequestOptions options,
  2. RequestInterceptorHandler handler
)

Called when the request is about to be sent.

Implementation

@override
void onRequest(RequestOptions options, RequestInterceptorHandler handler) {
  final data = options.data;
  final call = _target.startCall(
    client: 'dio',
    method: options.method,
    uri: options.uri,
    headers: _flatten(options.headers),
    body: data is FormData ? null : _bodyOf(data),
    formData: data is FormData ? _formFields(data) : null,
  );
  if (call != null) options.extra[_callKey] = call;
  handler.next(options);
}