Index: utils/pub/utils.dart |
diff --git a/utils/pub/utils.dart b/utils/pub/utils.dart |
index fd130da7ee1dfa4e62f3dec9aed430f058ae85a3..20aa140a6510f13e323b503ac57bfba4921232c5 100644 |
--- a/utils/pub/utils.dart |
+++ b/utils/pub/utils.dart |
@@ -173,24 +173,15 @@ void chainToCompleter(Future future, Completer completer) { |
/// Returns a [Future] that will complete to the first element of [stream]. |
/// Unlike [Stream.first], this is safe to use with single-subscription streams. |
Future streamFirst(Stream stream) { |
- // TODO(nweiz): remove this when issue 8512 is fixed. |
- var cancelled = false; |
var completer = new Completer(); |
var subscription; |
subscription = stream.listen((value) { |
- if (!cancelled) { |
- cancelled = true; |
- subscription.cancel(); |
- completer.complete(value); |
- } |
+ subscription.cancel(); |
+ completer.complete(value); |
}, onError: (e) { |
- if (!cancelled) { |
- completer.completeError(e.error, e.stackTrace); |
- } |
+ completer.completeError(e.error, e.stackTrace); |
}, onDone: () { |
- if (!cancelled) { |
- completer.completeError(new StateError("No elements")); |
- } |
+ completer.completeError(new StateError("No elements")); |
}, unsubscribeOnError: true); |
return completer.future; |
} |