I can't figure out what difference between .add
and .sink.add
?
Example:
StreamController myStreamController = StreamController();
stream = Stream<int>.periodic(Duration(seconds: 1), (t) => t + 1).take(3);
When I should do:
myStreamController.sink.add(myStreamController);
and when:
myStreamController.add(myStreamController);
It does the same. The purpose of the sink property are to provide a restricted interface for you streamcontroller:
Returns a view of this object that only exposes the StreamSink interface.
https://api.dart.dev/stable/2.5.0/dart-async/StreamController/sink.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With