http_client_interceptor
1.0.2, released 9 months ago by dasralph.de
Intercept and modify HTTP requests/responses using the http package.
WASM-ready
What it does
Provides a wrapper to add interceptors for logging, authentication, and error handling around HTTP calls. Works with the Dart http client and compatible libraries like Chopper and Dio compatibility layer.
AI-written summary of version 1.0.2, based on the package's README and metadata. Report an inaccuracy
Use it when
- You need to add custom headers or logging to all HTTP requests
- You want a simple way to handle errors centrally without modifying each call
- You are using the http package or compatible clients and need interceptor support
Skip it when
- You require interception for Image.network or other widgets that use dart:io HttpClient
- You need a full-featured HTTP client with built‑in interceptors like Dio
- You need code‑generation based API clients
Strengths
- Easy to integrate with existing http client code
- Supports chaining multiple interceptors
- Works with popular wrappers like Chopper and Retrofit compatibility layer
Weaknesses
- Limited to the http package ecosystem
- Cannot intercept low‑level HttpClient used by Flutter's Image.network
- Provides no code‑generation or advanced features like retry policies out of the box
Setup
- Kind
- Pure Dart
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 3
import 'package:http/http.dart' as http;
import 'package:http_client_interceptor/http_client_interceptor.dart';
final client = HttpClientProxy(interceptors:[
HttpInterceptorWrapper(onRequest:(req){
req.headers['Authorization']='Bearer TOKEN';
return OnRequest.next(req);
})
]);
final response = await client.get(Uri.parse('https://api.example.com/data'));
print(response.body);Alternatives
Packages that do the same job and could replace http_client_interceptor.