request method

Future<DocumentResponse> request(
  1. String location
)

Perform a virtual request to your app that renders the components and returns the resulting document.

Implementation

Future<DocumentResponse> request(String location) async {
  final uri = Uri.parse('http://test.server$location');

  final response = await _handler(Request('GET', uri));
  final statusCode = response.statusCode;
  final headers = response.headers;
  final body = await response.readAsString();

  final doc = statusCode == 200 ? parse(body) : null;

  return DocumentResponse(
    statusCode: statusCode,
    headers: headers,
    body: body,
    document: doc?.body != null ? doc : null,
  );
}