Source
Future<RemoteNode> getRemoteNode(String path) { var c = new Completer<RemoteNode>(); StreamSubscription sub; sub = list(path).listen((update) { if (!c.isCompleted) { c.complete(update.node); } if (sub != null) { sub.cancel(); } }, onError: (e, stack) { if (!c.isCompleted) { c.completeError(e, stack); } }, cancelOnError: true); return c.future; }