Skip to content
pubscout

dart_spawner

1.3.1, released 9 days ago by an unverified publisher

Runs Dart scripts, files, or URIs inside a new Isolate of the current Dart VM.

$ flutter pub add dart_spawner
Source repository

What it does

Spawns Dart scripts, files, or URIs inside a new Isolate of the current Dart VM. It supports executing scripts from strings, local files, or even external Dart projects using their respective dependencies.

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

Use it when

  • You need to run background tasks or isolated scripts inside the Dart VM.
  • You want to spawn a Dart file using dependencies from another Dart project or workspace.

Skip it when

  • You are targeting compiled AOT binaries (like dart compile exe) or platforms that do not support Isolate.spawnUri.
  • You only need standard isolates without loading external project dependencies.

Strengths

  • Can spawn code from external Dart projects or workspaces using their package configs.
  • Handles error and exit code tracking robustly across different VM states.

Weaknesses

  • Not supported outside the Dart VM or in compiled standalone executables.

Setup

Kind
Pure Dart
Effort
Low
Code generation
No
Direct dependencies
3

not documented

import 'package:dart_spawner/dart_spawner.dart';

void main() async {
  var spawner = DartSpawner();
  var script = "void main(List<String> args) { print('Hello from script'); }";
  var spawned = await spawner.spawnDart(script, []);
  await spawned.exitCode;
}

Alternatives

Packages that do the same job and could replace dart_spawner.

Works with

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