init method

Dio init()

Implementation

Dio init() {
  var dio = Dio();
  dio.options.baseUrl = baseURL;
  dio.options.connectTimeout = connectTimeout ?? 120.seconds;
  dio.options.receiveTimeout = receiveTimeout ?? 120.seconds;
  dio.options.headers = headers;
  if (useCache) {
    if (!kIsWeb) {
      dio.interceptors.add(cacheInterceptor(
          maxStale: maxStaleCache, hitCacheOnErrorExcept: hitCacheOnErrorExcept));
    }
  }
  dio.interceptors.add(ApiInterceptors(
      handleOnRequest: handleOnRequest ?? (value) {},
      handleResponse: handleOnResponse ?? (value) {},
      showLogging: showLogging,
      handleOnError: handleOnError ?? (_, __) {},
      handleWhenUnauthorized: handleWhenUnauthorized ?? () {}));
  return dio;
}