0

I have a stream of data and I want to add new value to an existing stream. Code looks like this

Stream<List<Points>> _points;
_points.sink.add(values);

is this possible, or do I have to find a different way?

2
  • StreamGroup()..add(_points)..add(anotherStream) Commented Sep 29, 2021 at 16:44
  • You may be looking for a StreamController -api.dart.dev/stable/2.14.3/dart-async/… Commented Sep 29, 2021 at 17:25

1 Answer 1

3

You can send data to a stream using the sink in a StreamController as well as add existing streams to the controller

// 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);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.