InterceptedClient.build constructor

InterceptedClient.build({
  1. required List<InterceptorContract> interceptors,
  2. Duration? requestTimeout,
  3. TimeoutCallback? onRequestTimeout,
  4. RetryPolicy? retryPolicy,
  5. Client? client,
})

Builds a new InterceptedClient instance.

Interceptors are applied in a linear order. For example a list that looks like this:

InterceptedClient.build(
  interceptors: [
    WeatherApiInterceptor(),
    LoggerInterceptor(),
  ],
),

Will apply first the WeatherApiInterceptor interceptor, so when LoggerInterceptor receives the request/response it has already been intercepted.

Implementation

factory InterceptedClient.build({
  required List<InterceptorContract> interceptors,
  Duration? requestTimeout,
  TimeoutCallback? onRequestTimeout,
  RetryPolicy? retryPolicy,
  Client? client,
}) =>
    InterceptedClient._internal(
      interceptors: interceptors,
      requestTimeout: requestTimeout,
      onRequestTimeout: onRequestTimeout,
      retryPolicy: retryPolicy,
      client: client,
    );