DioClient constructor

DioClient({
  1. required Dio dioClient,
  2. CacheOptions? globalCacheOptions,
  3. Iterable<Interceptor>? interceptors,
  4. 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;
  }
}