feat :
1 - search location and conditions 2 - parse list in isolate
This commit is contained in:
@@ -37,6 +37,7 @@ class DioRemote implements IHttpClient {
|
||||
ProgressCallback? onReceiveProgress,
|
||||
T Function(Map<String, dynamic> json)? fromJson,
|
||||
T Function(List<dynamic> json)? fromJsonList,
|
||||
Future<T> Function(List<dynamic> json)? fromJsonListAsync,
|
||||
}) async {
|
||||
final response = await dio.get(
|
||||
path,
|
||||
@@ -45,6 +46,10 @@ class DioRemote implements IHttpClient {
|
||||
onReceiveProgress: onReceiveProgress,
|
||||
cancelToken: ApiHandler.globalCancelToken,
|
||||
);
|
||||
if (fromJsonListAsync != null && response.data is List) {
|
||||
response.data = await fromJsonListAsync(response.data);
|
||||
return DioResponse<T>(response);
|
||||
}
|
||||
if (fromJsonList != null && response.data is List) {
|
||||
response.data = fromJsonList(response.data);
|
||||
return DioResponse<T>(response);
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
|
||||
import 'dart:typed_data';
|
||||
import 'package:dio/dio.dart';
|
||||
|
||||
import 'i_form_data.dart';
|
||||
import 'i_http_response.dart';
|
||||
|
||||
@@ -8,12 +7,14 @@ abstract class IHttpClient {
|
||||
Future<void> init();
|
||||
|
||||
Future<IHttpResponse<T>> get<T>(
|
||||
String path, {
|
||||
Map<String, dynamic>? queryParameters,
|
||||
Map<String, String>? headers,
|
||||
ProgressCallback? onReceiveProgress,
|
||||
});
|
||||
|
||||
String path, {
|
||||
Map<String, dynamic>? queryParameters,
|
||||
Map<String, String>? headers,
|
||||
ProgressCallback? onReceiveProgress,
|
||||
T Function(Map<String, dynamic> json)? fromJson,
|
||||
T Function(List<dynamic> json)? fromJsonList,
|
||||
Future<T> Function(List<dynamic> json)? fromJsonListAsync,
|
||||
});
|
||||
|
||||
Future<IHttpResponse<T>> post<T>(
|
||||
String path, {
|
||||
@@ -40,10 +41,7 @@ abstract class IHttpClient {
|
||||
Map<String, String>? headers,
|
||||
});
|
||||
|
||||
Future<IHttpResponse<T>> download<T>(
|
||||
String url, {
|
||||
ProgressCallback? onReceiveProgress,
|
||||
});
|
||||
Future<IHttpResponse<T>> download<T>(String url, {ProgressCallback? onReceiveProgress});
|
||||
|
||||
Future<IHttpResponse<T>> upload<T>(
|
||||
String path, {
|
||||
|
||||
Reference in New Issue
Block a user