Last active
June 7, 2023 07:17
-
-
Save OnlyTarg/957b9b0e4ec9f9e25aab9950be70405b to your computer and use it in GitHub Desktop.
async await
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 { | |
// 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