Skip to content

Instantly share code, notes, and snippets.

@AlexKenbo
Created March 9, 2020 17:08
Show Gist options
  • Save AlexKenbo/844bf0ef3ae378255144da3038d3e424 to your computer and use it in GitHub Desktop.
Save AlexKenbo/844bf0ef3ae378255144da3038d3e424 to your computer and use it in GitHub Desktop.
Stream method skipWhile
// asynchronous data
main() async {
Duration interval = Duration(seconds: 1);
Stream<int> stream = Stream<int>.periodic(interval,transform);
stream = stream.take(10);
stream = stream.skipWhile(condition);
await for(int i in stream){
print(i);
}
}
int transform(int x){
return (x + 1) * 2;
}
bool condition(int x){
return x < 5;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment