Last active
August 25, 2019 13:11
-
-
Save nickmeinhold/03d99d8fe47e64210ce6e6c33fabf7a4 to your computer and use it in GitHub Desktop.
Closing a StreamController calls onCancel and emits done event
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 controller; | |
controller = StreamController(onListen: () { | |
for (final number in [1, 2]) { | |
controller.add(number); | |
} | |
controller.close(); | |
}, | |
onCancel: () => print('onCancel')); | |
controller.stream.listen(print, onDone: () => print('onDone')); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment