Package selection guidance compiled from public package information, community data, and project usage.
flutter_qjs is a Flutter plugin that integrates the QuickJS JavaScript engine, enabling Dart applications to execute JavaScript code natively. It supports all major platforms except web, making it ideal for scenarios requiring lightweight, embedded scripting. The plugin provides a straightforward API to evaluate JS expressions, call functions, and exchange data between Dart and JavaScript. Built on the high-performance QuickJS project, it ensures fast execution with minimal overhead. This makes it suitable for dynamic logic, configuration scripts, or extending app functionality without recompilation.
Use cases
Running dynamic scripts in apps
Embedding JavaScript logic
Extending app behavior at runtime
Configuring app features via scripts
Interfacing with legacy JS code
Key features
Lightweight QuickJS engine
Cross-platform (except web)
Dart-JS interoperability
Simple API for script evaluation
Fast execution with low memory usage
Suitable for
Apps needing dynamic scripting
Developers using JS for logic
Plugins requiring embedded engines
Prototyping with scriptable components
Non-web mobile and desktop apps
Considerations
Not available on web platform
Limited to QuickJS-specific JS features
Requires careful error handling
May increase app size slightly
No support for modern ES modules
Original README
Original README snapshot from the linked source repository. Visit the repository for the latest content.
Method close can destroy quickjs runtime that can be recreated again if you call evaluate. Parameter port should be close to stop dispatch loop when you do not need it. Reference leak exception will be thrown since v0.3.3
notice: evaluation returning JSInvokable may cause reference leak.
You should manually call free to release JS reference.
(obj asJSRef).free();
// or JSRef.freeRecursive(obj);
Arguments passed into JSInvokable will be freed automatically. Use dup to keep the reference.
(obj asJSRef).dup();
// or JSRef.dupRecursive(obj);
Since v0.3.0, you can pass a function to JSInvokable arguments, and channel function is no longer included by default. You can use js function to set dart object globally.
For example, use Dio to implement http in qjs: