Skip to content

Instantly share code, notes, and snippets.

@cmc5788
Last active June 29, 2021 03:57
Show Gist options
  • Save cmc5788/37cda5d43194ff586e388d0fd2253bca to your computer and use it in GitHub Desktop.
Save cmc5788/37cda5d43194ff586e388d0fd2253bca to your computer and use it in GitHub Desktop.
Leaked stream in async
import 'dart:async';
Future<void> foo() async {
await for (final i in Stream<int>.periodic(const Duration(milliseconds: 500), (x) => x)) {
print('$i');
}
}
void main() async {
// once this is awaited, the inner implicit stream subscription is uncancalleble
await foo();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment