0%
Asynchronous Programming: Future, async, await — Chapter 15

Chapter 15 — Asynchronous Programming: Future, async, await

Part 1A — Learn Dart · Chapter 15 of 62 · 6 h

Chapter 15 — Asynchronous Programming: Future, async, await

Level: intermediate Estimated duration: 6 h Prerequisites: Chapter 13 — Exceptions and Error Handling, Chapter 14 — Functional Programming on Collections What you will be able to do by the end: write a program that waits for a long-running result (loading, network, file) without ever blocking the rest of the application, using Future, async, await, Future.wait(), and Stream.


15.0 — Chapter Objectives

By the end of this chapter, you will be able to:

  • explain why a long-running operation must never block the program;
  • distinguish synchronous processing from asynchronous processing;
  • explain what Dart's event loop is and why Dart is single-threaded;
  • predict the actual output order of an asynchronous program;
  • define a Future and name its three states;
  • create a Future with Future.delayed(), Future.value(), and Future.error();
  • use .then(), .catchError(), and .whenComplete();
  • write an async function and use await;
  • understand why an async function always returns a Future;
  • catch an asynchronous error with try / catch / finally;
  • recognize needlessly sequential await calls and parallelize them with Future.wait();
  • use unawaited for a future that is intentionally not awaited;
  • write an asynchronous main();
  • explain the difference between a Future and a Stream;
  • produce a Stream with async* and yield;
  • consume a Stream with await for and with listen();
  • transform a Stream with map and where;
  • explain why Flutter relies entirely on asynchronous programming.

Comments

Comments are powered by GitHub Discussions

Sign in with GitHub to join the discussion

Link copied!