Future<T> last

Returns the last element of the stream.

If an error event occurs before the first data event, the resulting future is completed with that error.

If this stream is empty (a done event occurs before the first data event), the resulting future completes with a StateError.


Future<T> get last {
  _Future<T> future = new _Future<T>();
  T result = null;
  bool foundResult = false;
      (T value) {
        foundResult = true;
        result = value;
      onError: future._completeError,
      onDone: () {
        if (foundResult) {
        try {
          throw IterableElementError.noElement();
        } catch (e, s) {
          _completeWithErrorCallback(future, e, s);
      cancelOnError: true);
  return future;