content: import 'package:dio/dio.dart';
  import 'package:pretty_dio_logger/pretty_dio_logger.dart';
  import 'package:tasky_app/Core/helpers/constants.dart';
  import 'package:tasky_app/Core/networking/app_interceptor.dart';
  
  
  import '../helpers/shared_pref_helper.dart';
  
  class DioFactory {
    DioFactory._();
  
    static Dio? dio;
  
    static Dio getDio() {
      Duration timeOut = const Duration(seconds: 30);
  
      if (dio == null) {
        dio = Dio();
        dio!
          ..options.connectTimeout = timeOut
          ..options.receiveTimeout = timeOut;
        addDioHeaders();
        addDioInterceptor();
        return dio!;
      } else {
        return dio!;
      }
    }
  
    static void addDioHeaders() async {
      dio?.options.headers = {
        'Accept': 'application/json',
        'Authorization':
            'Bearer ${await SharedPrefHelper.getSecuredString(SharedPrefKeys.accessToken)}',
      };
    }
  
    static void setTokenIntoHeaderAfterLogin(String token) {
  
      dio?.options.headers = {
        'Authorization': 'Bearer $token',
      };
    }
  
    static void addDioInterceptor() {
             dio?.interceptors.add(
    AppInterceptor() 
      );
      dio?.interceptors.add(
        PrettyDioLogger(
          requestBody: true,
          requestHeader: true,
          responseHeader: true,
        ),
   
      );
     
   
    }
  }
  