assureResponse<T> method Null safety

Response<T> assureResponse<T>(
  1. dynamic response,
  2. [RequestOptions? requestOptions]
)

Implementation

static Response<T> assureResponse<T>(response,
    [RequestOptions? requestOptions]) {
  if (response is! Response) {
    return Response<T>(
      data: response,
      requestOptions: requestOptions ?? RequestOptions(path: ''),
    );
  } else if (response is! Response<T>) {
    T? data = response.data;
    return Response<T>(
      data: data,
      headers: response.headers,
      requestOptions: response.requestOptions,
      statusCode: response.statusCode,
      isRedirect: response.isRedirect,
      redirects: response.redirects,
      statusMessage: response.statusMessage,
    );
  }
  return response;
}