简体   繁体   English

具有两个参数的Dart StreamController

[英]Dart StreamController with two arguments

I am currently developing on Flutter, using the BLoC pattern, and I would like to accept another parameter (or argument) in my StreamController . 我目前正在使用BLoC模式在Flutter上进行开发,并且我想在StreamController接受另一个参数(或参数)。 I could have used a Map or a class but is there a way to do it using Dart types? 我本可以使用Map或类,但是有没有办法使用Dart类型呢?

Is something similar to StreamController<int, String> possible? 是否可能类似于StreamController<int, String>

No. But you can instead make a Stream of a more complex object. 不会。但是您可以改为使更复杂的对象成为Stream

You could declare the following class: 您可以声明以下类:

class Foo {
  String val1;
  int val2;
}

And then create a Stream<Foo> 然后创建一个Stream<Foo>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM