Skip to content

Instantly share code, notes, and snippets.

@zohaib304
Created March 18, 2021 17:54
Show Gist options
  • Save zohaib304/da69f2d549700c4ffea75f96d5f17ce2 to your computer and use it in GitHub Desktop.
Save zohaib304/da69f2d549700c4ffea75f96d5f17ce2 to your computer and use it in GitHub Desktop.
Dart Streams (Bloc)
import "dart:async";
Stream<int> boatStream() async* {
for (int i = 0; i <= 10; i++) {
await Future.delayed(Duration(seconds: 2));
yield i;
}
}
void main() {
Stream<int> stream = boatStream();
stream.listen(
(data) {
print(data);
},
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment