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 request = DebugNetworkRequest(
    id: options.hashCode.toString(),
    url: options.uri.toString(),
    method: _parseMethod(options.method),
    headers: options.headers,
    body: options.data,
    requestTime: DateTime.now(),
    isLoading: true,
  );

  DebugNetworkLogger.logRequest(request);
  options.extra['debug_request_id'] = request.id;

  super.onRequest(options, handler);
}