File tree Expand file tree Collapse file tree 1 file changed +11
-3
lines changed
Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -33,7 +33,8 @@ class HtHttpClient {
3333 required bool isWeb,
3434 Dio ? dioInstance,
3535 List <Interceptor >? interceptors,
36- }) : _dio = dioInstance ?? Dio () {
36+ }) : _dio = dioInstance ?? Dio (),
37+ _isWeb = isWeb {
3738 // Configure base options
3839 final baseOptions = BaseOptions (
3940 baseUrl: baseUrl,
@@ -64,9 +65,12 @@ class HtHttpClient {
6465 // );
6566 }
6667
67- /// The configured Dio instance used for making requests.
68+ /// The Dio instance used for making requests.
6869 final Dio _dio;
6970
71+ /// Flag indicating if the client is operating in a web environment.
72+ final bool _isWeb;
73+
7074 /// Performs a GET request.
7175 ///
7276 /// - [path] : The endpoint path appended to the "baseUrl".
@@ -120,10 +124,14 @@ class HtHttpClient {
120124 Options ? options,
121125 CancelToken ? cancelToken,
122126 }) async {
127+ dynamic dataToSend = data;
128+ if (_isWeb && dataToSend == null ) {
129+ dataToSend = < String , dynamic > {}; // Use an empty map for null data on web
130+ }
123131 try {
124132 final response = await _dio.post <T >(
125133 path,
126- data: data ,
134+ data: dataToSend ,
127135 queryParameters: queryParameters,
128136 options: options,
129137 cancelToken: cancelToken,
You can’t perform that action at this time.
0 commit comments