Skip to content

Instantly share code, notes, and snippets.

@Grohden
Created September 5, 2020 01:51
Show Gist options
  • Save Grohden/8430ebb2f2cc046a9cf2f274aea06ae4 to your computer and use it in GitHub Desktop.
Save Grohden/8430ebb2f2cc046a9cf2f274aea06ae4 to your computer and use it in GitHub Desktop.
Sequential await vs non sequential
void main() async {
final list = [1,6,3,2,4,5];
print('Sequential');
for(final time in list) {
await Future.delayed(Duration(seconds: time));
print(time);
}
print('Not sequential');
list.forEach((time) async {
await Future.delayed(Duration(seconds: time));
print(time);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment