Flutter 中的 Sink 和 Stream 有什么区别? [英] What is the difference between Sink and Stream in Flutter?

查看:22
本文介绍了Flutter 中的 Sink 和 Stream 有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

关于 Flutter 的

Google I/O 2018 视频解释了如何使用 Dart 流管理 Flutter 应用程序中的状态.演讲者谈到使用Sink作为输入流和Stream作为输出流.SinkStream 有什么区别?我搜索了文档,但没有说太多谢谢.

The Google I/O 2018 video about Flutter explains how to use Dart streams to manage state in a Flutter application. The speaker talked about using Sink as input stream and Stream as output stream. What is the difference between Sink and Stream? I searched the documentation but it doesn't say too much thanks.

推荐答案

A StreamSink 是一个 StreamConsumer,这意味着它可以接受多个流(由 addStream) 并处理这些流发出的事件.

A StreamSink is a StreamConsumer, which means it can take several streams (added by addStream) and processes the events these streams emit.

如果它是 StreamControllerStreamSink,那么来自添加的流的所有事件都由 StreamController 创建的流发出.

If it is the StreamSink of a StreamController then all events from the added streams are emitted by the stream created by the StreamController.

通过这种方式,您可以通过管道(转发)一个或多个流到另一个流中.

This way you can pipe (forward) one or more streams into another one.

这篇关于Flutter 中的 Sink 和 Stream 有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆