WdDio constructor

WdDio({
  1. BaseOptions? options,
  2. List<Interceptor>? interceptorList,
  3. bool debug = false,
})

Implementation

WdDio({
  BaseOptions? options,
  this.interceptorList,
  this.debug = false,
}) {
  this.options = options ?? BaseOptions();
  // 禁止重定向
  this.options.followRedirects = false;

  // 状态码错误视为成功
  this.options.validateStatus = (status) => true;

  httpClientAdapter = getAdapter();

  // 拦截器
  if (interceptorList != null) {
    for (var item in interceptorList!) {
      this.interceptors.add(item);
    }
  }

  // debug
  if (debug == true) {
    this.interceptors.add(LogInterceptor(responseBody: true));
  }
}