Skip to content

Instantly share code, notes, and snippets.

@OnlyTarg
Last active June 7, 2023 07:17
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 OnlyTarg/957b9b0e4ec9f9e25aab9950be70405b to your computer and use it in GitHub Desktop.
Save OnlyTarg/957b9b0e4ec9f9e25aab9950be70405b to your computer and use it in GitHub Desktop.
async await
void main() async {
// final bool1 = await getSomeFuture1();
// final bool2 = await getSomeFuture2();
final bool3 = await getSomeFuture3();
// print(bool1);
// print(bool2);
print(bool3);
}
Future<bool> getSomeFuture3() async {
print('before async func');
final isCoolFeature = await Future.delayed(Duration(seconds: 1)).then((v) {
print('in async');
return true;
});
print('after async func');
return isCoolFeature;
}
// Future<bool> getSomeFuture1() async {
// final isCoolFeature =
// await Future.delayed(Duration(seconds: 1)).then((v) => true);
// return isCoolFeature;
// }
// Future<bool> getSomeFuture2() async {
// return Future.delayed(Duration(seconds: 1)).then((v) => true);
// }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment