feat : captcha widget.dart
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:pretty_dio_logger/pretty_dio_logger.dart';
|
||||
import 'package:rasadyar_core/infrastructure/remote/interfaces/i_form_data.dart';
|
||||
|
||||
@@ -15,7 +16,9 @@ class DioRemote implements IHttpClient {
|
||||
@override
|
||||
Future<void> init() async {
|
||||
final dio = Dio(BaseOptions(baseUrl: baseUrl));
|
||||
dio.interceptors.add(PrettyDioLogger());
|
||||
if (kDebugMode) {
|
||||
dio.interceptors.add(PrettyDioLogger());
|
||||
}
|
||||
_dio = dio;
|
||||
}
|
||||
|
||||
@@ -40,6 +43,7 @@ class DioRemote implements IHttpClient {
|
||||
String path, {
|
||||
dynamic data,
|
||||
Map<String, dynamic>? queryParameters,
|
||||
T Function(Map<String, dynamic> json)? fromJson,
|
||||
Map<String, String>? headers,
|
||||
ProgressCallback? onSendProgress,
|
||||
ProgressCallback? onReceiveProgress,
|
||||
@@ -52,6 +56,15 @@ class DioRemote implements IHttpClient {
|
||||
onSendProgress: onSendProgress,
|
||||
onReceiveProgress: onReceiveProgress,
|
||||
);
|
||||
|
||||
if (fromJson != null) {
|
||||
final rawData = response.data;
|
||||
final parsedData =
|
||||
rawData is Map<String, dynamic> ? fromJson(rawData) : null;
|
||||
response.data = parsedData;
|
||||
return DioResponse<T>(response);
|
||||
}
|
||||
|
||||
return DioResponse<T>(response);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user