我有一个数据流,我想要向现有的数据流添加新的价值。代码如下所示
Stream<List<Points>> _points;
_points.sink.add(values);这是可能的吗,或者我必须找到一种不同的方法?
发布于 2021-09-29 17:31:53
您可以使用StreamController和add existing streams to the controller中的接收器将数据发送到流
// Create controller
final streamController = StreamController<List<Point>>();
// Listen to stream
streamController.stream.listen((points) { doStuff(points); });
// Send data to stream
streamController.sink.add([const Point(0.0, 0.0), const Point(1.0, 1.0)]);
// You can also add other streams to the controller
streamController.addStream(otherStream);https://stackoverflow.com/questions/69380287
复制相似问题