DioNetworkClient constructor

DioNetworkClient({
  1. required Map<String, String> commonHeadersProvider(),
  2. @visibleForTesting HttpClientAdapter? httpClientAdapter,
})

Implementation

DioNetworkClient({
  required this.commonHeadersProvider,
  @visibleForTesting HttpClientAdapter? httpClientAdapter,
}) {
  if (httpClientAdapter != null) _dio.httpClientAdapter = httpClientAdapter;
  _dio.interceptors.add(
    InterceptorsWrapper(
      onRequest: (options, handler) {
        // A header the call site set explicitly wins over the common one.
        options.headers = {
          ..._buildCommonHeaders(),
          ...options.headers,
        };
        handler.next(options);
      },
    ),
  );
}