Stream<T> onDone<T>(Stream<T> stream, void Function() onDone) => stream.transform(StreamTransformer.fromHandlers(handleDone: (sink) { sink.close(); onDone(); }));