request method
Perform a virtual request to your app that renders the components and returns the resulting document.
Implementation
Future<DocumentResponse> request(String location, {String? handlerPath}) async {
final uri = Uri.parse('http://test.server$location');
final response = await _handler(Request('GET', uri, handlerPath: handlerPath));
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,
);
}