Created
February 22, 2019 16:07
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Read the full article -> https://creativebracket.com/how-to-use-streams-in-dart-1/