Created
July 25, 2020 14:53
-
-
Save jodinathan/debe316efaae6fc748b2c390a00b5e65 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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