flutter_jolt 0.1.0
flutter_jolt: ^0.1.0 copied to clipboard
Rust-powered JavaScript runtime for Flutter. JSC on Apple, QuickJS elsewhere, host JS on web.
flutter_jolt #
Flutter plugin for Jolt — a Rust-powered JavaScript runtime that picks the best engine per platform.
| Platform | Engine | Bundle cost |
|---|---|---|
| iOS / macOS | JavaScriptCore | 0 (system framework) |
| Android / Linux / Windows | QuickJS | ~1 MB |
| Web | Host browser JS | 0 |
Usage #
import 'package:flutter_jolt/flutter_jolt.dart';
// Initialize once (in main)
await RustLib.init();
// Create a runtime
final rt = JoltRuntime();
// Evaluate JavaScript
final result = await rt.eval(code: '1 + 1');
// Globals
await rt.setGlobal(name: 'x', value: JsValue.int_(42));
final x = await rt.getGlobal(name: 'x');
// Call JS functions
await rt.eval(code: 'function greet(n) { return "Hello, " + n; }');
final greeting = await rt.callFunction(
name: 'greet',
args: [JsValue.string('Flutter')],
);
Installation #
dependencies:
flutter_jolt: ^0.1.0
Requires Rust toolchain for native compilation. The plugin uses Cargokit to build Rust code automatically during flutter build / flutter run.
License #
MIT — see LICENSE.