fix : dio call

This commit is contained in:
2025-05-17 09:08:46 +03:30
parent 3a017b5956
commit b5d6055aa7
6 changed files with 159 additions and 18 deletions

View File

@@ -1,10 +1,9 @@
import 'package:dio/dio.dart';
import 'package:flutter/foundation.dart';
import 'package:pretty_dio_logger/pretty_dio_logger.dart';
import 'package:rasadyar_core/core.dart';
import 'package:rasadyar_core/infrastructure/remote/interfaces/i_form_data.dart';
import 'dio_form_data.dart';
import 'dio_response.dart';
import 'interfaces/i_http_client.dart';
class DioRemote implements IHttpClient {
@@ -29,7 +28,7 @@ class DioRemote implements IHttpClient {
Map<String, String>? headers,
ProgressCallback? onReceiveProgress,
}) async {
final response = await _dio.get<T>(
final response = await _dio.get(
path,
queryParameters: queryParameters,
options: Options(headers: headers),
@@ -48,7 +47,7 @@ class DioRemote implements IHttpClient {
ProgressCallback? onSendProgress,
ProgressCallback? onReceiveProgress,
}) async {
final response = await _dio.post<T>(
final response = await _dio.post(
path,
data: data,
queryParameters: queryParameters,
@@ -57,6 +56,8 @@ class DioRemote implements IHttpClient {
onReceiveProgress: onReceiveProgress,
);
eLog(response.toString());
if (fromJson != null) {
final rawData = response.data;
final parsedData =
@@ -65,7 +66,7 @@ class DioRemote implements IHttpClient {
return DioResponse<T>(response);
}
return DioResponse<T>(response);
return DioResponse<T>(response );
}
@override
@@ -77,7 +78,7 @@ class DioRemote implements IHttpClient {
ProgressCallback? onSendProgress,
ProgressCallback? onReceiveProgress,
}) async {
final response = await _dio.put<T>(
final response = await _dio.put(
path,
data: data,
queryParameters: queryParameters,
@@ -124,7 +125,7 @@ class DioRemote implements IHttpClient {
Map<String, String>? headers,
ProgressCallback? onSendProgress,
}) async {
final response = await _dio.post<T>(
final response = await _dio.post(
path,
data: (formData as DioFormData).raw,
options: Options(headers: headers, contentType: 'multipart/form-data'),

View File

@@ -2,7 +2,7 @@ import 'interfaces/i_http_response.dart';
import 'package:dio/dio.dart';
class DioResponse<T> implements IHttpResponse<T> {
final Response<T> _response;
final Response<dynamic> _response;
DioResponse(this._response);