Created
January 6, 2022 23:10
-
-
Save RedsAnDev/921c5c513ebc84d70cd5ce42e7877a72 to your computer and use it in GitHub Desktop.
Play with stream
This file contains hidden or 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
| Stream<List<int>> bgFunction(int size)async*{ | |
| int counter=size>10?size:10; | |
| List<int> buffer=[]; | |
| while(counter>=0){ | |
| buffer=[]; | |
| yield buffer; | |
| for(int i=size;i>counter;i--) | |
| buffer.add(i); | |
| buffer.add(counter); | |
| counter--; | |
| } | |
| } | |
| void main() async{ | |
| var c=await bgFunction(200); | |
| c.toList().then((List<List<int>> e){ | |
| print(e); | |
| e.forEach((List<int> single_list){ | |
| print("SINGLE LIST IS ${single_list}"); | |
| }); | |
| }); | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment