Hi there, there are many things about streams that are still perplexing to me, for example:
Future<AuthError?> connect(String user, String pw) {
connectStream.take(1).listen((_) { return null; }, onError: (error) { return error;});
return resultOfStream?
}
What is the accepted way to return null from the function if there is a single result or the error if there is an error? I know I can return await Completer().future at the end of the function but that seems rather messy. Is that the only way?
I was trying to figure out how to rework the stream so that it put null into a Future on a good result and put the error into a future on a bad result and return the result of the connect stream directly but couldn't figure that out.