DebugInterceptor class
Dio interceptor that emits structured, verbose debug information through a user-supplied callback.
Lucky Dart has no built-in logging dependency. Instead, you wire
DebugInterceptor to your own debug output mechanism by providing the
onDebug callback. The callback receives a named event string
('request', 'response', or 'error'), a short human-readable
message, and a data map containing every observable field of the
request or response — making it straightforward to dump to a structured
logger, a developer console, or a debugging overlay.
The interceptor is only added to Dio when the connector's debugMode
flag is true and an onDebug callback is provided.
Unlike LoggingInterceptor, DebugInterceptor always fires on every request and response; there is no per-request opt-out flag.
DebugInterceptor(
onDebug: ({required event, message, data}) {
// Route to your preferred debug sink, e.g. `print` or a dev-tools
// overlay.
print('[DEBUG:$event] $message — $data');
},
);
Constructors
- DebugInterceptor({required LuckyDebugCallback onDebug})
-
Creates a DebugInterceptor with the required
onDebugcallback.
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- onDebug → LuckyDebugCallback
-
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 -
Emits an
'error'debug event containing the full error context. -
onRequest(
RequestOptions options, RequestInterceptorHandler handler) → void -
Emits a
'request'debug event containing the full request context. -
onResponse(
Response response, ResponseInterceptorHandler handler) → void -
Emits a
'response'debug event containing the full response context. -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited