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.
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.
- isolate_channel
Communication channels for isolates based on Flutter's platform channels.
82Compare - puby
Run Dart and Flutter commands across multiple projects in the current directory.
68Compare - script_runner
Runs configurable project scripts from a YAML/JSON file via a CLI tool.
43Compare - flavor_getter
Plugin to read current app flavor from native code
42Compare
Works with
Packages commonly used together with dart_spawner: ones it builds on, ones built on it, and its own family.
- yamldart_spawner depends on itA Dart library for parsing YAML documents into Dart data structures.
- async_extensiondart_spawner depends on itDart async extensions for Future, FutureOr, and performance improvements.
- bones_apiBuilt on dart_spawnerA powerful API backend framework for Dart with HTTP server, routing, SQL translator, and DB adapters.