dioPost static method
dynamic
dioPost({})
POST request of DIO
Implementation
static dioPost({required String urlPath, dynamic body, Map<String, dynamic>? queryPara, Map<String, dynamic>? headers}) async {
try {
final res = await _dio.post(urlPath, data: body, queryParameters: queryPara, options: Options(headers: headers));
return res;
} on PlatformException {
return Failure(ErrorResponse(
unifiedHttpClientEnum: UnifiedHttpClientEnum.platformExceptionError,
errorResponseHolder: ErrorResponseHolder(defaultMessage: 'Platform Exception Caught')));
} on SocketException catch (e) {
return Failure(ErrorResponse(
unifiedHttpClientEnum: UnifiedHttpClientEnum.socketExceptionError,
errorResponseHolder: ErrorResponseHolder(defaultMessage: 'Socket Exception:$e')));
} on FormatException {
return Failure(ErrorResponse(
unifiedHttpClientEnum: UnifiedHttpClientEnum.formatExceptionError,
errorResponseHolder: ErrorResponseHolder(defaultMessage: 'format exception Error')));
} on DioException catch (e) {
debugPrint('error of dioexp : ${e.type}');
} catch (e) {
return Failure(ErrorResponse(
unifiedHttpClientEnum: UnifiedHttpClientEnum.undefined,
errorResponseHolder: ErrorResponseHolder(defaultMessage: 'something went Wrong : $e')));
}
}