put method
Future<OutputType?>
put(
- Map<String, Object> primaryKeys,
- Map<String, dynamic> data, {
- Options? options,
- CancelToken? cancelToken,
- void onReceiveProgress(
- int total,
- int finish
)?,
- void onSendProgress(
- int total,
- int finish
)?,
})
Implementation
Future<OutputType?> put(
Map<String, Object> primaryKeys,
Map<String, dynamic> data, {
Options? options,
CancelToken? cancelToken,
void Function(int total, int finish)? onReceiveProgress,
void Function(int total, int finish)? onSendProgress,
}) async {
final response = await dio.put<String>(
pathBuild(),
data: data.toJson(),
queryParameters: primaryKeys,
options: options,
cancelToken: cancelToken,
onReceiveProgress: onReceiveProgress,
onSendProgress: onSendProgress,
);
if ([200, 201].contains(response.statusCode)) {
final map = response.data?.toMap();
if (map == null) return null;
return fromMap(map);
} else {
throw response.statusMessage ?? response.data ?? "Error";
}
}