InAppLogDioInterceptor class
Dio interceptor for logging API requests and responses to in_app_logview.
This interceptor captures all HTTP requests and responses made through Dio and displays them in the in-app log viewer with detailed information.
Usage:
import 'package:dio/dio.dart';
import 'package:in_app_logview/in_app_logview.dart';
final dio = Dio();
dio.interceptors.add(InAppLogDioInterceptor());
// Now all API calls will be logged
final response = await dio.get('https://api.example.com/data');
Customization:
dio.interceptors.add(
InAppLogDioInterceptor(
logRequest: true,
logResponse: true,
logError: true,
logRequestHeaders: false, // Hide sensitive headers
logResponseHeaders: false,
),
);
Constructors
- InAppLogDioInterceptor({bool logRequest = true, bool logResponse = true, bool logError = true, bool logRequestHeaders = true, bool logResponseHeaders = true, bool logRequestBody = true, bool logResponseBody = true, String tag = 'API'})
- Creates a new InAppLogDioInterceptor.
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- logError → bool
-
Whether to log error details.
final
- logRequest → bool
-
Whether to log request details.
final
- logRequestBody → bool
-
Whether to include request body in logs.
final
- logRequestHeaders → bool
-
Whether to include request headers in logs.
final
- logResponse → bool
-
Whether to log response details.
final
- logResponseBody → bool
-
Whether to include response body in logs.
final
- logResponseHeaders → bool
-
Whether to include response headers in logs.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- tag → String
-
Custom tag for API logs (default: 'API').
final
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