Created
March 18, 2021 17:54
-
-
Save zohaib304/da69f2d549700c4ffea75f96d5f17ce2 to your computer and use it in GitHub Desktop.
Dart Streams (Bloc)
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"; | |
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