dart_monty_native 0.7.3
dart_monty_native: ^0.7.3 copied to clipboard
Native plugin for dart_monty (replaces dart_monty_desktop). Pure Dart bindings for Monty — a restricted sandboxed Python interpreter built in Rust.
dart_monty_native #
Part of dart_monty — pure Dart bindings for Monty, a restricted, sandboxed Python interpreter built in Rust.
This package is co-designed by human and AI — nearly all code is AI-generated.
Flutter plugin — native implementation of dart_monty using FFI. Runs the Monty Python interpreter in a background Isolate for non-blocking execution from Flutter apps on macOS, Linux, Windows, iOS, and Android.
Requires Flutter. This package is not intended for direct use. Import dart_monty instead — the federated plugin system selects this package automatically on native platforms.
How It Works #
DartMontyNative registers itself as the MontyPlatform instance via Flutter's dartPluginClass mechanism. It delegates to dart_monty_ffi for Isolate-based FFI execution.
As of 0.7.0, MontyNative, NativeIsolateBindings, and NativeIsolateBindingsImpl have moved to dart_monty_ffi (making the Isolate bridge usable without Flutter). This package re-exports them for backward compatibility and serves as the Flutter plugin registration shim.
Bundled Binaries #
This package vendors pre-built native libraries for supported platforms:
macos/libdart_monty_native.dyliblinux/libdart_monty_native.so
Usage #
This package registers itself automatically. In your Flutter app, use the public API:
import 'package:dart_monty/dart_monty.dart';
import 'package:dart_monty_platform_interface/dart_monty_platform_interface.dart';
Future<void> main() async {
// MontyPlatform.instance is set to MontyNative on desktop automatically.
// MontyNative runs the interpreter in a background Isolate.
final monty = MontyPlatform.instance;
final result = await monty.run('2 + 2');
print(result.value); // 4
await monty.dispose();
}
See the main dart_monty repository for full documentation.