dart_monty 0.4.3 copy "dart_monty: ^0.4.3" to clipboard
dart_monty: ^0.4.3 copied to clipboard

Pure Dart bindings for Monty, a restricted sandboxed Python interpreter built in Rust. Run Python from Dart and Flutter on desktop, web, and mobile.

example/example.dart

// Printing to stdout is expected in an example.
// ignore_for_file: avoid_print
import 'package:dart_monty/dart_monty.dart';

Future<void> main() async {
  final monty = MontyPlatform.instance;

  // Run a simple Python expression.
  final result = await monty.run('2 + 2');
  print('Result: ${result.value}'); // 4

  // Run with resource limits.
  final limited = await monty.run(
    'sum(range(100))',
    limits: MontyLimits(timeoutMs: 5000, memoryBytes: 10 * 1024 * 1024),
  );
  print('Sum: ${limited.value}'); // 4950

  // Handle errors.
  final bad = await monty.run('1 / 0');
  if (bad.isError) {
    print('Error: ${bad.error!.message}');
  }

  await monty.dispose();
}
0
likes
140
points
188
downloads

Publisher

unverified uploader

Weekly Downloads

Pure Dart bindings for Monty, a restricted sandboxed Python interpreter built in Rust. Run Python from Dart and Flutter on desktop, web, and mobile.

Repository (GitHub)
View/report issues
Contributing

Topics

#python #sandbox #interpreter #flutter

Documentation

API reference

License

MIT (license)

Dependencies

dart_monty_desktop, dart_monty_platform_interface, dart_monty_web, flutter

More

Packages that depend on dart_monty

Packages that implement dart_monty