Created
May 7, 2021 09:49
-
-
Save Sloy/273843ecbb46f81de6d2061e9fae2dce to your computer and use it in GitHub Desktop.
Playing with dart async/await delayed
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
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