http_interceptor
3.0.0, released 7 months ago by codingale.dev
Intercept requests and responses in Dart's http package with support for retries and timeouts.
WASM-ready
What it does
Allows you to intercept, modify, and log HTTP requests and responses from Dart's standard http package. It provides support for custom retry policies, JSON decoding helpers, and query parameters management.
AI-written summary of version 3.0.0, based on the package's README and metadata. Report an inaccuracy
Use it when
- You want to use Dart's standard http package but need request/response interception for authentication tokens, logging, or headers.
- You need automatic request retries upon specific response codes or network exceptions.
Skip it when
- You are already using a networking library like Dio that has its own built-in interceptors.
Strengths
- Seamless integration with Dart's standard http package.
- Flexible retry policies supporting exponential backoff.
- Built-in JSON response parsing helpers.
Weaknesses
- Not compatible with Flutter Web when using self-signed certificates via dart:io IOClient.
- Major version upgrades can contain breaking changes requiring migration.
Setup
- Kind
- Pure Dart
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 1
Not documented
class LoggerInterceptor implements HttpInterceptor {
@override
BaseRequest interceptRequest({required BaseRequest request}) {
print('----- Request -----');
print(request.toString());
return request;
}
@override
BaseResponse interceptResponse({required BaseResponse response}) {
print('----- Response -----');
print('Code: ${response.statusCode}');
return response;
}
}Alternatives
Packages that do the same job and could replace http_interceptor.
Works with
Packages commonly used together with http_interceptor: ones it builds on, ones built on it, and its own family.