buildNonCachedDio method

Future<DioBuilderResponse> buildNonCachedDio(
  1. {bool hasAuth = false,
  2. bool shouldQueue = false,
  3. bool passDomain = false}
)

Implementation

Future<DioBuilderResponse> buildNonCachedDio({
  bool hasAuth = false,
  bool shouldQueue = false,
  bool passDomain = false,
}) async {
  final Options dioOptions = _getDioOptions();
  final String token = await TokenManager().getToken();
  final Dio dio = Dio(
    BaseOptions(
      baseUrl: Environment.currentEnv.baseUrl,
      connectTimeout: const Duration(milliseconds: 15000),
      receiveTimeout: const Duration(milliseconds: 15000),
      headers: hasAuth
          ? {
              'Authorization': 'Bearer $token',
              'Content-Type': 'application/json',
            }
          : {
              'Content-Type': 'application/json',
            },
    ),
  );
  dio.interceptors.add(DioInterceptor(dio));
  if (shouldQueue) dio.interceptors.add(QueuedInterceptor());
  return DioBuilderResponse(dio: dio, dioOptions: dioOptions);
}