post<T> method
Future<Result<T> >
post<T>(
- String path, {
- dynamic data,
- Map<
String, dynamic> ? queryParameters, - FutureOr<
T> onSuccess(- dynamic data
- FutureOr<
T> onError(- dynamic data
- RestApiClientRequestOptions? options,
- bool cacheEnabled = false,
override
Implementation
@override
Future<Result<T>> post<T>(
String path, {
data,
Map<String, dynamic>? queryParameters,
FutureOr<T> Function(dynamic data)? onSuccess,
FutureOr<T> Function(dynamic data)? onError,
RestApiClientRequestOptions? options,
bool cacheEnabled = false,
}) async {
try {
final response = await _dio.post(
path,
data: data,
queryParameters: queryParameters,
options: options?.toOptions(),
);
if (cacheEnabled) {
await cacheHandler.set(response);
}
return NetworkResult(
response: response,
data: await _resolveResult(response.data, onSuccess),
);
} on DioException catch (e) {
await exceptionHandler.handle(e, silent: options?.silentException);
return NetworkResult(
response: e.response,
exception: e,
statusCode: e.response?.statusCode,
statusMessage: e.response?.statusMessage,
);
}
}