TracedDioInterceptor class
dio Interceptor that records every request into the
inspector timeline. The interceptor hooks the three dio
lifecycle callbacks:
onRequest: starts a pending record (via ApiTrace.call) and stashes a Completer on the requestextramap.onResponse: completes the stashed completer with the finalResponse, which causes the pending record to be appended to the timeline with status + duration.onError: completes the completer with theDioExceptionso the record carries the failure.
Constructors
- TracedDioInterceptor({String nameFor(RequestOptions options)?, bool deferToHttpOverrides = true})
-
Creates the interceptor. The optional
nameForcallback lets callers customize the timeline label (default:"<METHOD> <path>"). The callback receives theRequestOptionsso the caller can use headers, query parameters, etc.const
Properties
- deferToHttpOverrides → bool
-
When
true(the default) and aTracedHttpOverrideshas been installed in this isolate, this interceptor records nothing: Dio's default adapter routes throughdart:io HttpClient, so the overrides layer already captures the call and recording here would produce a duplicate timeline entry.final - hashCode → int
-
The hash code for this object.
no setterinherited
- nameFor → String Function(RequestOptions options)?
-
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
onError(
DioException err, ErrorInterceptorHandler handler) → void - Called when an exception was occurred during the request.
-
onRequest(
RequestOptions options, RequestInterceptorHandler handler) → void - Called when the request is about to be sent.
-
onResponse(
Response response, ResponseInterceptorHandler handler) → void - Called when the response is about to be resolved.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited