isolated_worker
0.1.1, released 5 years ago by an unverified publisher
Singleton isolated worker for running heavy tasks in isolates on Flutter and web workers on web.
What it does
Provides a singleton isolated worker that runs heavy computational tasks in a separate Isolate on mobile/desktop platforms and via Web Workers on the web. It mimics Flutter's compute function syntax and includes a WorkerDelegator to handle shared platform execution.
AI-written summary of version 0.1.1, based on the package's README and metadata. Report an inaccuracy
Use it when
- You need to run heavy background calculations without blocking the main UI thread.
- You need a cross-platform solution that supports both Dart Isolates and Web Workers with a similar API.
Skip it when
- You only need simple one-off background tasks where Flutter's built-in compute function is sufficient.
- You are working entirely on platforms where standard Dart isolates or Isolate.run already satisfy all your background processing requirements.
Strengths
- Identical syntax to Flutter's compute function.
- Cross-platform support including web via Web Workers.
- WorkerDelegator simplifies sharing execution logic across platforms.
Weaknesses
- Web workers require manual setup of a worker.js file in the web folder.
- Web worker execution cannot directly use Dart closures as messages due to web platform limitations.
Setup
- Kind
- Pure Dart
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 1
For web support, you must download a worker.js file and place it in the web directory of your Flutter project.
int doSomeHeavyCalculation(int count) {
return count;
}
void main() {
IsolatedWorker().run(doSomeHeavyCalculation, 1000);
}Alternatives
Packages that do the same job and could replace isolated_worker.
- squadron
Multithreading and worker thread pools for Dart and Flutter using Isolates and Web Workers.
87Compare - worker_bee
Cross-platform isolated worker runtime for Dart Web, VM, and Flutter
82Compare - worker_manager
Manage CPU-intensive calculations across isolates with reusable workers and cancellation.
74Compare - isolate_manager
Manage long-lived isolates across native, Web, and WASM platforms with built-in queuing and workers.
66Compare