Skip to content

Instantly share code, notes, and snippets.

Last active May 15, 2019 23:59
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Stream Example
import 'dart:async';
class Cake {}
class Order {
String type;
void main() {
final controller = StreamController();
final order = new Order('chocolate');
final baker = new StreamTransformer.fromHandlers(
handleData: (cakeType, sink) {
if (cakeType == 'chocolate') {
sink.add(new Cake());
} else {
sink.addError('I cant bake that type');
controller.sink.add(order); => order.type).transform(baker).listen(
(cake) => print('Heres your cake $cake'),
onError: (err) => print(err));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment