Created
August 18, 2022 07:48
-
-
Save FlutterZeroGit/74c278ea5c9318b5f6f5eeb594dfc2f7 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
main() async { | |
task1(); | |
String result = await task2(); | |
task3(result); | |
} | |
void task1() { | |
print('タスク1完了'); | |
} | |
Future task2() async { | |
String result = 'タスク2未完了'; | |
await Future.delayed(Duration(seconds: 3), () { | |
result = 'タスク2完了'; | |
}); | |
return result; | |
} | |
void task3(task2) { | |
print('タスク2結果: $task2'); | |
print('タスク3完了'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment