DioClient constructor
DioClient({
- required Dio dioClient,
- CacheOptions? globalCacheOptions,
- Iterable<
Interceptor> ? interceptors, - HttpClientAdapter? httpClientAdapter,
Creates an instance of DioClient.
Requires a configured Dio
instance (dioClient
).
Optionally accepts globalCacheOptions
for default caching behavior,
a list of interceptors
to add to the Dio instance, and a custom
httpClientAdapter
.
Implementation
DioClient({
required Dio dioClient,
this.globalCacheOptions,
Iterable<Interceptor>? interceptors,
HttpClientAdapter? httpClientAdapter,
}) : _dio = dioClient {
// Add provided interceptors to the Dio instance.
if (interceptors != null) {
_dio.interceptors.addAll(interceptors);
}
// Set the custom HttpClientAdapter if provided.
if (httpClientAdapter != null) {
_dio.httpClientAdapter = httpClientAdapter;
}
}