Skip to content

Instantly share code, notes, and snippets.

@werediver
Created October 13, 2022 14:09
Show Gist options
  • Save werediver/fce9591ef6d5b3928ccb4a1ae446d9c9 to your computer and use it in GitHub Desktop.
Save werediver/fce9591ef6d5b3928ccb4a1ae446d9c9 to your computer and use it in GitHub Desktop.
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