isolate_handler
1.0.2, released 4 years ago by tramontana.co.hu
Abstraction layer for Dart isolates with inter-isolate communication and plugin support.
What it does
Provides a simple API to spawn isolates and automatically establish a communication channel. Isolates can call Flutter plugins via a background view, enabling plugin usage from background threads.
AI-written summary of version 1.0.2, based on the package's README and metadata. Report an inaccuracy
Use it when
- Need to run CPU‑intensive Dart code off the main thread
- Want to call Flutter plugins from an isolate without manual channel setup
- Require named isolates for easy reference and cleanup
Skip it when
- Tasks that spend most time in native plugin code (no performance gain)
- Applications that already use custom isolate solutions or need fine‑grained control over ports
Strengths
- Easy spawn and messaging API
- Automatic plugin support via flutter_isolate
- Named isolates for convenient lookup and disposal
Weaknesses
- No performance benefit when calling native plugins
- Relies on flutter_isolate which may add overhead
- Limited to Flutter projects
Setup
- Kind
- Flutter widgets
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 1
Add flutter_isolate dependency; no build_runner or native permissions required
final isolates = IsolateHandler();
void main() {
isolates.spawn<int>(entryPoint,
name: "counter",
onReceive: setCounter,
onInitialized: () => isolates.send(counter, to: "counter")
);
}
void setCounter(int count) {
counter = count;
print("Counter is now $counter");
isolates.kill("counter");
}
void entryPoint(Map<String, dynamic> context) {
final messenger = HandledIsolate.initialize(context);
messenger.listen((count) {
messenger.send(++count);
});
}Alternatives
Packages that do the same job and could replace isolate_handler.
- isolate_channel
Communication channels for isolates based on Flutter's platform channels.
82Compare - stream_channel
An abstraction for two-way communication channels based on the Dart Stream class.
79Compare - easy_isolate
Provides a simple abstraction over Dart isolates for running code on background threads.
53Compare - iso
Runs code in a Dart isolate with bidirectional stream communication.
30Compare
Works with
Packages commonly used together with isolate_handler: ones it builds on, ones built on it, and its own family.