putRequest method
API Put Method
Implementation
Future<dynamic> putRequest(
String endUrl,
dynamic body, {
String? contentType,
Decoder? decoder,
Map<String, String>? headers,
Map<String, dynamic>? query,
Progress? uploadProgress,
}) async {
_debugLog('PUT Request - URL: $endUrl');
_debugLog('PUT Body: $body');
final connectivityResult = await (Connectivity().checkConnectivity());
if (connectivityResult.length <= 1 &&
connectivityResult.first == ConnectivityResult.none) {
_debugLog('No internet connection detected', isError: true);
throw _handleInternetError();
}
try {
headers ?? _headers;
_debugLog('Sending PUT request to: $_baseUrl$endUrl');
final response = await put(endUrl, body,
contentType: contentType,
decoder: decoder,
headers: headers,
query: query,
uploadProgress: uploadProgress);
_debugLog('PUT Response - Status: ${response.statusCode}');
return processAndHandleResponse(response);
} on GetHttpException catch (ex) {
_debugLog('PUT GetHttpException: ${ex.message}', isError: true);
throw _handleError(ex);
} on UnauthorizedException catch (ex) {
_debugLog('PUT UnauthorizedException: $ex', isError: true);
throw _handleError(ex);
} on UnexpectedFormat catch (ex) {
_debugLog('PUT UnexpectedFormat: ${ex.message}', isError: true);
throw _handleError(ex);
} on Exception catch (ex) {
_debugLog('PUT Exception: $ex', isError: true);
throw _handleError(ex);
} on FlutterErrorDetails catch (ex) {
_debugLog('PUT FlutterErrorDetails: ${ex.exceptionAsString()}',
isError: true);
throw _handleError(ex);
}
}