Flutterアプリは常に非同期操作(ネットワークリクエスト、ファイルアクセス、データベースクエリ)を処理します。DartのFutures(単一の非同期結果)とStreams(非同期イベントのシーケンス)、async/awaitとFutureBuilder/StreamBuilderなどのウィジェットは、非同期UIに必須です。
Futuresとasync/await
// a Future represents a single async result that completes later
Future<String> fetchUser() async {
final response = await http.get(url); // await pauses until the Future completes
return response.body; // returns the result
}
// using it
final data = await fetchUser(); // await the result
// or: fetchUser().then((data) => ...); // callback style
