Skip to content
pubscout

actors

0.11.0, released 3 years ago by an unverified publisher

Thin wrapper around Dart Isolates implementing the Actor Model

WASM-ready
$ flutter pub add actors
Source repository

What it does

Makes working with Dart Isolates easier by wrapping them in an Actor model. Supports maintaining private internal state, streaming responses, and managing groups of actors with different strategies.

AI-written summary of version 0.11.0, based on the package's README and metadata. Report an inaccuracy

Use it when

  • You need to offload CPU-intensive tasks to separate isolates easily
  • You want to manage isolated states with message passing

Skip it when

  • You are targeting the web where this library's worker implementation is not yet complete
  • Simple asynchronous async/await without isolates is sufficient for your workload

Strengths

  • Simplifies Isolate management
  • Supports stateful actors and actor groups with strategies like RoundRobin and MultiHandler
  • Provides a unified Messenger interface for local and isolated execution

Weaknesses

  • Web support is currently a TODO
  • Passing actors via Sendable adds a small performance overhead

Setup

Kind
Pure Dart
Effort
Low
Code generation
No
Direct dependencies
0
class Accumulator with Handler<int, int> {
  int _value;
  Accumulator([int initialValue = 0]): _value = initialValue;
  int handle(int n) => _value += n;
}

main() async {
  final actor = Actor.create(() => Accumulator(6));
  print(await actor.send(5)); // 11
  await actor.close();
}

Alternatives

Packages that do the same job and could replace actors.

  • adb

    A Dart wrapper for interacting with the Android Debug Bridge (adb).

  • isolate_channel

    Communication channels for isolates based on Flutter's platform channels.

  • universal_web

    Wrapper that allows importing web APIs in non-web environments

  • serial

    Wrapper for the Web Serial API to use serial ports in Flutter web.

Works with

Packages commonly used together with actors: ones it builds on, ones built on it, and its own family.