Skip to content

Commit f0b3b7b

Browse files
committed
refactor: Add isWeb flag to disable timeouts on web
- Disable timeouts on web - Added isWeb flag
1 parent 6e9f630 commit f0b3b7b

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

lib/src/ht_http_client.dart

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,19 +30,26 @@ class HtHttpClient {
3030
HtHttpClient({
3131
required String baseUrl,
3232
required TokenProvider tokenProvider,
33+
required bool isWeb,
3334
Dio? dioInstance,
3435
List<Interceptor>? interceptors,
3536
}) : _dio = dioInstance ?? Dio() {
3637
// Configure base options
37-
_dio.options = BaseOptions(
38+
final baseOptions = BaseOptions(
3839
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
4240
// Headers can be set here, but AuthInterceptor handles Authorization
4341
// headers: {'Content-Type': 'application/json'},
4442
);
4543

44+
if (!isWeb) {
45+
baseOptions
46+
..connectTimeout = const Duration(seconds: 15)
47+
..receiveTimeout = const Duration(seconds: 15)
48+
..sendTimeout = const Duration(seconds: 15);
49+
}
50+
51+
_dio.options = baseOptions;
52+
4653
// Add default interceptors
4754
_dio.interceptors.addAll([
4855
AuthInterceptor(tokenProvider: tokenProvider),

0 commit comments

Comments
 (0)