NetworkInputStream class
An InputStream implementation that reads bytes from a Dart Stream<List<int>>.
This is typically used to wrap network response streams such as
HttpClientResponse
in Dart.
The class buffers incoming chunks and provides methods to read the stream byte-by-byte in a non-blocking manner.
Example usage:
final response = await HttpClient().getUrl(Uri.parse('https://example.com'));
final inputStream = NetworkInputStream(response);
int byte;
while ((byte = await inputStream.readByte()) != -1) {
print(byte);
}
await inputStream.close();
- Inheritance
-
- Object
- InputStream
- NetworkInputStream
Constructors
-
NetworkInputStream(Stream<
List< _sourceStream)int> > - An InputStream implementation that reads bytes from a Dart Stream<List<int>>.
Properties
Methods
-
available(
) → Future< int> -
Returns an estimate of the number of bytes that can be read (or skipped over)
from this input stream without blocking by the next invocation of a method
for this input stream.
override
-
checkClosed(
) → void -
Checks if the stream is closed and throws an exception if it is.
inherited
-
close(
) → Future< void> -
Closes this input stream and releases any system resources associated
with the stream.
override
-
mark(
int readLimit) → void -
Marks the current position in this input stream.
override
-
markSupported(
) → bool -
Tests if this input stream supports the mark and reset methods.
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
read(
List< int> b, [int offset = 0, int? length]) → Future<int> -
Reads some number of bytes from the input stream and stores them into
the buffer array
b
.inherited -
readAll(
) → Future< Uint8List> -
Reads all remaining bytes from the input stream.
inherited
-
readByte(
) → Future< int> -
Reads the next byte of data from the input stream.
override
-
readFully(
int length) → Future< Uint8List> -
Reads exactly
length
bytes from the input stream.inherited -
reset(
) → Future< void> -
Repositions this stream to the position at the time the mark method
was last called on this input stream.
override
-
skip(
int n) → Future< int> -
Skips over and discards
n
bytes of data from this input stream.inherited -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited