dart-concurrency-isolates
Managing Dart Concurrency and Isolates
Contents
- Core Guidelines
- Choosing the Right Isolate Strategy
- Implementing One-Off Tasks
- Implementing Long-Running Workers
- Workflows
- Examples
Core Guidelines
- Isolate Memory: Assume zero shared memory between isolates. Isolates communicate exclusively via message passing.
- Data Transfer: Avoid passing large mutable objects between isolates. Prefer simple data types or immutable records to minimize serialization overhead.
- Resource Management: Always ensure isolates and ports are terminated when no longer needed to prevent memory leaks.
- Platform Limitations: Do not use isolates on the Dart Web platform. Web compiles to JavaScript, which uses Web Workers instead.
- Related Skills: Refer to
dart-async-programmingfor standard asynchronous operations (Future,Stream,async/await) running on the Main Isolate.
Choosing the Right Isolate Strategy
More from dart-lang/skills
dart-add-unit-test
Write and organize unit tests for functions, methods, and classes using `package:test`. Use when creating new logic or fixing bugs to ensure code remains correct and regression-free.
2.1Kdart-fix-runtime-errors
Uses get_runtime_errors and lsp to fetch an active stack trace, locate the failing line, apply a fix, and verify resolution via hot_reload.
2.1Kdart-run-static-analysis
Execute `dart analyze` to identify warnings and errors, and use `dart fix --apply` to automatically resolve mechanical lint issues. Use during development to ensure code quality and before committing changes.
2.1Kdart-use-pattern-matching
Use switch expressions and pattern matching where appropriate
2.1Kdart-resolve-package-conflicts
Workflow for fixing package version conflicts. Use this when `pub get` fails due to incompatible package versions.
2.1Kdart-collect-coverage
Collect coverage using the coverage packge and create an LCOV report
2.0K