dart-async-programming

Installation
SKILL.md

Writing Asynchronous Dart Code

Contents

Core Guidelines

Write asynchronous Dart code using modern, declarative patterns. Avoid legacy callback-based approaches. Assume all network, file I/O, and database operations are asynchronous.

  • Use async/await: Always prefer async and await over raw .then(), .catchError(), or .whenComplete() chains. This flattens the execution flow and improves readability.
  • Handle Errors Gracefully: Wrap all await calls in try-catch blocks to handle exceptions. Do not rely on unhandled future rejections.
  • Execute Concurrently: Use Future.wait to initiate and await multiple independent futures concurrently rather than awaiting them sequentially.
  • Consume Streams Sequentially: Prefer await for over .forEach() or .listen() when consuming streams, unless you specifically need low-level subscription management (like pausing or resuming).
  • Prevent Memory Leaks: Always call .close() on a StreamController when it is no longer needed or when the owning class is disposed.
Related skills
Installs
70
GitHub Stars
214
First Seen
Mar 17, 2026