copyWith<T> static method

Response<T> copyWith<T>(
  1. Response response, {
  2. required String message,
  3. T? data,
  4. dynamic error,
  5. dynamic extra,
  6. String? body,
  7. required int statusCode,
  8. Map<String, List<String>>? headers,
})

Implementation

static Response<T> copyWith<T>(
  Response response, {
  required String message,
  T? data,
  dynamic error,
  dynamic extra,
  String? body,
  required int statusCode,
  Map<String, List<String>>? headers,
}) {
  if (response is ResponseCustomError) {
    return ResponseCustomError<T>(
        message: message,
        data: data,
        error: error,
        body: body,
        statusCode: statusCode,
        headers: headers,
        extra: extra);
  }
  if (response is ResponseMappingFail) {
    return ResponseMappingFail<T>(
        message: message, error: error, body: body, statusCode: statusCode, headers: headers, extra: extra);
  }
  if (response is ResponseNoInternetConnection) {
    return ResponseNoInternetConnection<T>(
        message: message, error: error, body: body, statusCode: statusCode, headers: headers, extra: extra);
  }
  if (response is ResponseNoInternetConnection) {
    return ResponseNoInternetConnection<T>(
        message: message, error: error, body: body, statusCode: statusCode, headers: headers, extra: extra);
  }
  if (response is ResponseConnectionTimeout) {
    return ResponseConnectionTimeout<T>(
        message: message, error: error, body: body, statusCode: statusCode, headers: headers, extra: extra);
  }
  if (response is ResponseCancel) {
    return ResponseCancel<T>(
        message: message, error: error, body: body, statusCode: statusCode, headers: headers, extra: extra);
  }
  if (response is ResponseFailedHostLookup) {
    return ResponseFailedHostLookup<T>(
        message: message, error: error, body: body, statusCode: statusCode, headers: headers, extra: extra);
  }
  if (response is ResponseUnknownFail) {
    return ResponseUnknownFail<T>(
        message: message, error: error, body: body, statusCode: statusCode, headers: headers, extra: extra);
  }
  return Response<T>(
    message: message,
    data: data,
    error: error,
    extra: extra,
    body: body,
    statusCode: statusCode,
    headers: headers,
  );
}