Skip to content

Instantly share code, notes, and snippets.

@jodinathan
Created July 25, 2020 14:53
Show Gist options
  • Save jodinathan/debe316efaae6fc748b2c390a00b5e65 to your computer and use it in GitHub Desktop.
Save jodinathan/debe316efaae6fc748b2c390a00b5e65 to your computer and use it in GitHub Desktop.
import 'dart:async';
class A {
var ctrl = StreamController();
var cc = 0;
run() {
ctrl.stream.forEach((ev) {
print(ev ?? 0);
});
Timer.periodic(Duration(seconds: 1), (tm) {
ctrl?.add(cc++);
});
}
}
void main() async {
var a = A();
a.run();
Timer(Duration(seconds: 5), () {
a = null;
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment