expectResponse function Null safety

TestResponse expectResponse(
  1. TestResponse response,
  2. int statusCode,
  3. {dynamic body,
  4. Map<String, dynamic>? headers}
)

A convenience for expect with hasResponse.

This method is equivalent to:

    expect(response, hasResponse(statusCode, body, headers: headers));

The actual response is returned from this method for quick composition:

    final response = expectResponse(
      await client.request("/foo").get(),
      200, body: "foo", headers: {"x-foo": "foo"});
    print("$response");

Implementation

TestResponse expectResponse(TestResponse response, int statusCode,
    {dynamic body, Map<String, dynamic>? headers}) {
  expect(response, hasResponse(statusCode, body: body, headers: headers));
  return response;
}