Skip to content

Instantly share code, notes, and snippets.

@RedsAnDev
Created January 6, 2022 23:10
Show Gist options
  • Select an option

  • Save RedsAnDev/921c5c513ebc84d70cd5ce42e7877a72 to your computer and use it in GitHub Desktop.

Select an option

Save RedsAnDev/921c5c513ebc84d70cd5ce42e7877a72 to your computer and use it in GitHub Desktop.
Play with stream
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