Created
October 13, 2022 14:09
-
-
Save werediver/fce9591ef6d5b3928ccb4a1ae446d9c9 to your computer and use it in GitHub Desktop.
This file contains 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 { | |
await variant1(); | |
variant2(); | |
print("xxx"); | |
} | |
Future<void> variant1() async { | |
final result = await y(); | |
// async gap | |
print("y: $result"); | |
final result2 = await x(); | |
// async gap | |
print("x: $result"); | |
print("aaa"); | |
} | |
void variant2() { | |
y().then(/* async gap */ (result) { | |
print("y: $result"); | |
x().then(/* async gap */ (result2) { | |
print("x: $result"); | |
print("aaa"); | |
}); | |
}); | |
} | |
Future<int> y() async { | |
return 1 + 2; | |
} | |
Future<int> x() async { | |
return 2 + 3; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment