getById method

Future<OutputType?> getById(
  1. Object id, {
  2. Options? options,
  3. CancelToken? cancelToken,
  4. void onReceiveProgress(
    1. int total,
    2. 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";
  }
}