I have a custom StreamController<int>:
final StreamController listener = StreamController<int>.broadcast();
After initialization, I emit a value to the stream
listener.add(7);
After emitting the value, I set a Stream listener
listener.stream.listen((val) {
print(val);
});
The expected behavior is that the listener will return the previously set value, however, that's not the case. Only if I set the value after I set the listener, the listener will be called.
How can I achieve that behavior?
(Edit: Multiple listeners have to be supported)