openStream method
Opens a connection to this Url and returns an InputStream to read from it.
This is a convenience method that:
- Creates a UrlConnection
- Connects to the URL
- Returns the input stream for the response body
Throws a NetworkException on failure.
Example
final stream = await Url('https://example.com').openStream();
Implementation
Future<InputStream> openStream() async {
final connection = openConnection();
await connection.connect();
return connection.getInputStream();
}