Created
March 9, 2020 05:57
-
-
Save AlexKenbo/b0f13a7f258de4add0b9e038769357fa to your computer and use it in GitHub Desktop.
Stream - 1
This file contains hidden or 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