Skip to content

Instantly share code, notes, and snippets.

@tejainece
Created June 8, 2018 09:08
Show Gist options
  • Save tejainece/7a7a55bada6a97ed1bc4221606592e4f to your computer and use it in GitHub Desktop.
Save tejainece/7a7a55bada6a97ed1bc4221606592e4f to your computer and use it in GitHub Desktop.
import 'dart:async';
Stream<int> stream() async* {
int k = 0;
while (k < 10) yield k++;
}
void main() async {
await for(int i in stream()) {
print('Starting $i ...');
await new Future.delayed(new Duration(seconds: 2));
print('Finishing $i ...');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment