首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >向流中添加新价值

向流中添加新价值
EN

Stack Overflow用户
提问于 2021-09-29 16:31:46
回答 1查看 44关注 0票数 0

我有一个数据流,我想要向现有的数据流添加新的价值。代码如下所示

代码语言:javascript
复制
Stream<List<Points>> _points;
_points.sink.add(values);

这是可能的吗,或者我必须找到一种不同的方法?

EN

回答 1

Stack Overflow用户

发布于 2021-09-29 17:31:53

您可以使用StreamControlleradd existing streams to the controller中的接收器将数据发送到流

代码语言:javascript
复制
// 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);
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/69380287

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档