dart_monty
dart_monty runs restricted Python from Dart and Flutter on native and web
platforms. It adds stateful runtimes, Dart host functions, extensions, event
streams, and OS-call policy to the pool and session primitives supplied by
dart_monty_core.
Installation
dart pub add dart_monty
Or add to pubspec.yaml:
dependencies:
dart_monty: ^0.120.1
Quick start
import 'package:dart_monty/dart_monty.dart';
Future<void> main() async {
final runtime = await MontyRuntime.start();
try {
await runtime.execute('x = 41').result;
final value = await runtime.execute('x + 1').result;
print(value.dartValue); // 42
} finally {
await runtime.dispose();
}
}
See Choosing an API for the runtime and direct session tradeoffs.
Platform support
The Dart VM and Flutter native targets use the prebuilt native worker that
dart_monty_core downloads from its GitHub release at build time. Browser
targets need core's Web Worker and WASM assets plus cross-origin isolation
headers. See Installation and
Deployment and Bundling for setup.
Documentation
- Stateful and concurrent execution
- Host functions
- Extensions
- Sandbox lifecycle and isolation
- Filesystem and workspace policy
- Failure propagation
- Testing
The public declarations are listed in
lib/dart_monty.dart.
License
The package uses the MIT License.
Libraries
- dart_monty
- Runs restricted Python through native and web workers.