post method
Sends a POST request to the specified uri.
uri: The endpoint to which the POST request is sent.
data: The data to be sent in the request body.
queryParameters: Optional query parameters.
options: Optional request options.
cancelToken: A token to cancel the request.
onSendProgress: A callback for tracking upload progress.
onReceiveProgress: A callback for tracking response progress.
Returns the response data. Throws Exceptions if response data is invalid,
Implementation
Future<dynamic> post(
String uri, {
data,
Map<String, dynamic>? queryParameters,
Options? options,
CancelToken? cancelToken,
ProgressCallback? onSendProgress,
ProgressCallback? onReceiveProgress,
}) async {
try {
var response = await _dio.post(
uri,
data: data,
queryParameters: queryParameters,
options: options,
cancelToken: cancelToken,
onSendProgress: onSendProgress,
onReceiveProgress: onReceiveProgress,
);
return response.data;
} on FormatException catch (_) {
throw const FormatException("Unable to process the data");
} catch (e) {
rethrow;
}
}