getById method
Future<OutputType?>
getById(
- Object id, {
- Options? options,
- CancelToken? cancelToken,
- void onReceiveProgress(
- int total,
- int finish
)?,
})
Implementation
Future<OutputType?> getById(
Object id, {
Options? options,
CancelToken? cancelToken,
void Function(int total, int finish)? onReceiveProgress,
}) async {
final response = await dio.get<String>(
pathBuild(),
queryParameters: {"id": id},
options: options,
cancelToken: cancelToken,
onReceiveProgress: onReceiveProgress,
);
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";
}
}