Dart API Referencedart:ioChunkedInputStream

ChunkedInputStream abstract class

A chunked input stream wraps a basic input stream and supplies binary data in configurable chunk sizes.

abstract class ChunkedInputStream {
  /**
   * Adds buffering to an input stream and provide the ability to read
   * the data in known size chunks.
   */
  factory ChunkedInputStream(InputStream input, [int chunkSize = 0]) {
    return new _ChunkedInputStream(input, chunkSize);
  }

  /**
   * Reads [chunkSize] bytes from the stream. If [chunkSize] bytes are
   * not currently available null is returned. When the stream is
   * closed the last call can return with less than [chunkSize] bytes.
   */
  List<int> read();

  /**
   * Returns whether the stream has been closed. There might still be
   * more data to read.
   */
  bool get closed;

  /**
   * Returns the chunk size used by this stream.
   */
  int get chunkSize;

  /**
   * Sets the chunk size used by this stream.
   */
  void set chunkSize(int chunkSize);

  /**
   * Sets the handler that gets called when at least [chunkSize] bytes
   * of data is available or the underlying stream has been closed and
   * there is still unread data.
   */
  void set onData(void callback());

  /**
   * Sets the handler that gets called when there will be no more data
   * available in the stream.
   */
  void set onClosed(void callback());

  /**
   * Sets the handler that gets called when the underlying
   * communication channel gets into some kind of error situation.
   */
  void set onError(void callback(e));
}

Constructors

factory ChunkedInputStream(InputStream input, [int chunkSize = 0]) #

Adds buffering to an input stream and provide the ability to read the data in known size chunks.

factory ChunkedInputStream(InputStream input, [int chunkSize = 0]) {
  return new _ChunkedInputStream(input, chunkSize);
}

Properties

int get chunkSize #

Returns the chunk size used by this stream.

int get chunkSize;

void set chunkSize(int chunkSize) #

Sets the chunk size used by this stream.

void set chunkSize(int chunkSize);

final bool closed #

Returns whether the stream has been closed. There might still be more data to read.

bool get closed;

void set onClosed(void callback()) #

Sets the handler that gets called when there will be no more data available in the stream.

void set onClosed(void callback());

void set onData(void callback()) #

Sets the handler that gets called when at least chunkSize bytes of data is available or the underlying stream has been closed and there is still unread data.

void set onData(void callback());

void set onError(void callback(e)) #

Sets the handler that gets called when the underlying communication channel gets into some kind of error situation.

void set onError(void callback(e));

Methods

List<int> read() #

Reads chunkSize bytes from the stream. If chunkSize bytes are not currently available null is returned. When the stream is closed the last call can return with less than chunkSize bytes.

List<int> read();