asStream method
Create a Stream that emits the current value and its future changes.
Implementation
Stream<T> asStream() {
late final ReactionDisposer disposer;
late final StreamController<T> controller;
controller = StreamController(
onListen: () {
disposer = autorun((_) => controller.add(value));
},
onCancel: () {
disposer.call();
},
);
return controller.stream;
}