Skip to content

Instantly share code, notes, and snippets.

@Sloy
Created May 7, 2021 09:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Sloy/273843ecbb46f81de6d2061e9fae2dce to your computer and use it in GitHub Desktop.
Save Sloy/273843ecbb46f81de6d2061e9fae2dce to your computer and use it in GitHub Desktop.
Playing with dart async/await delayed
void main() async {
Stopwatch stopwatch = new Stopwatch()..start();
var p1 = delay(Duration(seconds: 2));
var p2 = delay(Duration(seconds: 4));
await p1;
await p2;
print('Executed in ${stopwatch.elapsed}');
}
Future delay(duration) => Future.delayed(duration);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment