listen method

Future listen()

Starts listening to the underlying stream.

Returns a Future that will complete when the connection is closed or when it has an error. This is the same as done.

listen may only be called once.

Implementation

Future listen() {
  _channel.stream.listen(_handleResponse, onError: (error, stackTrace) {
    _done.completeError(error, stackTrace);
    _channel.sink.close();
  }, onDone: () {
    if (!_done.isCompleted) _done.complete();
    close();
  });
  return done;
}