initDio static method

Dio initDio({
  1. required String baseUrl,
  2. Interceptor? interceptor,
  3. String proxy = '',
})

Implementation

static Dio initDio(
    {required String baseUrl, Interceptor? interceptor, String proxy = ''}) {
  if (fastDio == null) {
    final BaseOptions options = BaseOptions(
      connectTimeout: CONNECT_TIMEOUT,
      receiveTimeout: RECEIVE_TIMEOUT,
      baseUrl: baseUrl,
    );

    final _dio = Dio(options);

    if (interceptor != null) {
      _dio.interceptors.add(interceptor);
    }
    fastDio = _dio;

    if (proxy.isNotEmpty) {
      setProxy(fastDio!, proxyUrl: proxy);
    }
  }
  return fastDio!;
}