Skip to content

Instantly share code, notes, and snippets.

@FlutterZeroGit
Created August 18, 2022 07:48
Show Gist options
  • Save FlutterZeroGit/74c278ea5c9318b5f6f5eeb594dfc2f7 to your computer and use it in GitHub Desktop.
Save FlutterZeroGit/74c278ea5c9318b5f6f5eeb594dfc2f7 to your computer and use it in GitHub Desktop.
非同期処理: async/awaitあり
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