无法收听广播流
Not able to listen to a broadcast Stream
我的标准流:
var stream = (StreamController<int>()..add(1)).stream;
stream.listen(print); // prints 1
我的直播流:
var stream = (StreamController<int>.broadcast()..add(1)).stream;
stream.listen(print); // doesn't print anything
与标准流不同,当没有侦听器时,广播流不会缓冲事件。先声明广播流,监听后添加事件
var controller= StreamController<int>.broadcast();
controller.stream.listen(print);
controller.sink.add(1); // will print 1
我的标准流:
var stream = (StreamController<int>()..add(1)).stream;
stream.listen(print); // prints 1
我的直播流:
var stream = (StreamController<int>.broadcast()..add(1)).stream;
stream.listen(print); // doesn't print anything
与标准流不同,当没有侦听器时,广播流不会缓冲事件。先声明广播流,监听后添加事件
var controller= StreamController<int>.broadcast();
controller.stream.listen(print);
controller.sink.add(1); // will print 1