|
|
|
|
@ -4,6 +4,7 @@ import 'dart:developer';
|
|
|
|
|
import 'dart:io';
|
|
|
|
|
|
|
|
|
|
import 'package:easy_localization/easy_localization.dart';
|
|
|
|
|
import 'package:flutter/foundation.dart';
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/core/api/http_client_manager.dart';
|
|
|
|
|
import 'package:hmg_patient_app_new/core/api_consts.dart';
|
|
|
|
|
@ -243,10 +244,13 @@ class ApiClientImp implements ApiClient {
|
|
|
|
|
|
|
|
|
|
// Handle body encoding based on isBodyPlainText flag
|
|
|
|
|
final dynamic requestBody = isBodyPlainText ? body : json.encode(body);
|
|
|
|
|
debugPrint("uri: ${Uri.parse(url.trim())}");
|
|
|
|
|
var requestBodyJSON = json.encode(body);
|
|
|
|
|
// debugPrint("body: $requestBodyJSON", wrapWidth: 2048);
|
|
|
|
|
log("body: $requestBodyJSON");
|
|
|
|
|
|
|
|
|
|
if (kDebugMode) {
|
|
|
|
|
debugPrint("uri: ${Uri.parse(url.trim())}");
|
|
|
|
|
var requestBodyJSON = json.encode(body);
|
|
|
|
|
debugPrint("body: $requestBodyJSON", wrapWidth: 2048);
|
|
|
|
|
// log("body: $requestBodyJSON");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
http.Response response;
|
|
|
|
|
try {
|
|
|
|
|
@ -255,7 +259,7 @@ class ApiClientImp implements ApiClient {
|
|
|
|
|
body: requestBody,
|
|
|
|
|
headers: headers,
|
|
|
|
|
);
|
|
|
|
|
log("response: ${response.body.toString()}");
|
|
|
|
|
// log("response: ${response.body.toString()}");
|
|
|
|
|
} on SocketException catch (e) {
|
|
|
|
|
final message = e.message.contains('Connection reset by peer') ? LocaleKeys.networkConnectionReset.tr() : LocaleKeys.networkErrorMessage.tr();
|
|
|
|
|
onFailure(message, -1, failureType: ConnectivityFailure(message));
|
|
|
|
|
|