stream method
Processes the response as a byte stream.
This method is useful for handling large responses or when you need to process the response data incrementally.
Returns a Future that resolves to a ByteStream of the response body.
Throws ServiceError if the request fails or returns an error status.
Example
final stream = await request('/api/files/large-file')
.get()
.stream();
await for (final chunk in stream) {
// Process chunk incrementally
}
Implementation
Future<http.ByteStream> stream() async {
final response = await _request.send();
await _checkResponse(response);
return response.stream;
}