var mStream = new StreamController();
with fixed type:
var mStream = new StreamController<String>();
//else
StramController<String> mStream = new StreamController<String>();
//else
StreamController<String> mStream = new StreamController();
//Note: For fixed type Stream you need to provide type on transform handleData arguments
mStream.sink.add("Tareq");
//
mStream.add("Islam");
mStream.listen(
(item) { print(item)},
onError: (err) => print(err);
);
var mTransform== new StreamTransformer.fromHandlers(
handleData: (String item , sink){
if(item !="Tareq"){
sink.add(item +" rakib");
}else{
sink.addError("item is not right");
}
},
);
Stream<String> stream = new Stream.fromFuture(getData());
print("Created the stream");
stream.listen((data) {
print("DataReceived: "+data);
}, onDone: () {
print("Task Done");
}, onError: (error) {
print("Some Error");
});
only single subscriber available. {Default in Dart}
StreamController<String> streamController = new StreamController();
multiple subscriber available.
StreamController<String> streamController = new StreamController.broadcast();