Skip to content

Instantly share code, notes, and snippets.

@graphicbeacon
Created February 22, 2019 16:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save graphicbeacon/3baf3a9c229dcfa962878905e478a1a7 to your computer and use it in GitHub Desktop.
Save graphicbeacon/3baf3a9c229dcfa962878905e478a1a7 to your computer and use it in GitHub Desktop.
Solution for "How to use Streams in Dart (Part 1)" blog post series
import 'dart:async';
void main() {
var streamController = StreamController();
streamController.stream.listen(
(data) => print('Got eem! $data'),
onError: (err) => print('Got an error! $err'),
onDone: () => print('Mission complete!'),
cancelOnError: false,
);
streamController.sink.add('Foo');
streamController.sink.addError('Houston, we have a problem!');
streamController.sink.close();
}
@graphicbeacon
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment