@@ -30,27 +30,19 @@ class HtHttpClient {
3030 HtHttpClient ({
3131 required String baseUrl,
3232 required TokenProvider tokenProvider,
33- required bool isWeb,
3433 Dio ? dioInstance,
3534 List <Interceptor >? interceptors,
36- }) : _dio = dioInstance ?? Dio (),
37- _isWeb = isWeb {
35+ }) : _dio = dioInstance ?? Dio () {
3836 // Configure base options
39- final baseOptions = BaseOptions (
37+ _dio.options = BaseOptions (
4038 baseUrl: baseUrl,
39+ connectTimeout: const Duration (seconds: 15 ), // Example timeout
40+ receiveTimeout: const Duration (seconds: 15 ), // Example timeout
41+ sendTimeout: const Duration (seconds: 15 ), // Example timeout
4142 // Headers can be set here, but AuthInterceptor handles Authorization
4243 // headers: {'Content-Type': 'application/json'},
4344 );
4445
45- if (! isWeb) {
46- baseOptions
47- ..connectTimeout = const Duration (seconds: 15 )
48- ..receiveTimeout = const Duration (seconds: 15 )
49- ..sendTimeout = const Duration (seconds: 15 );
50- }
51-
52- _dio.options = baseOptions;
53-
5446 // Add default interceptors
5547 _dio.interceptors.addAll ([
5648 AuthInterceptor (tokenProvider: tokenProvider),
@@ -65,12 +57,9 @@ class HtHttpClient {
6557 // );
6658 }
6759
68- /// The Dio instance used for making requests.
60+ /// The configured Dio instance used for making requests.
6961 final Dio _dio;
70-
71- /// Flag indicating if the client is operating in a web environment.
72- final bool _isWeb;
73-
62+
7463 /// Performs a GET request.
7564 ///
7665 /// - [path] : The endpoint path appended to the "baseUrl".
@@ -124,14 +113,10 @@ class HtHttpClient {
124113 Options ? options,
125114 CancelToken ? cancelToken,
126115 }) async {
127- dynamic dataToSend = data;
128- if (_isWeb && dataToSend == null ) {
129- dataToSend = < String , dynamic > {}; // Use an empty map for null data on web
130- }
131116 try {
132117 final response = await _dio.post <T >(
133118 path,
134- data: dataToSend ,
119+ data: data ,
135120 queryParameters: queryParameters,
136121 options: options,
137122 cancelToken: cancelToken,
@@ -206,4 +191,4 @@ class HtHttpClient {
206191 rethrow ;
207192 }
208193 }
209- }
194+ }
0 commit comments