flutter_qjs는 Dart 애플리케이션이 네이티브로 JavaScript 코드를 실행할 수 있도록 해주는 Flutter 플러그인입니다. 웹을 제외한 모든 주요 플랫폼을 지원하며, 경량의 내장 스크립팅이 필요한 시나리오에 이상적입니다. 이 플러그인은 JS 표현식 평가, 함수 호출, Dart와 JavaScript 간 데이터 교환을 위한 간단한 API를 제공합니다. 고성능 QuickJS 프로젝트 기반으로 구축되어 최소한의 오버헤드로 빠른 실행을 보장합니다. 동적 로직, 구성 스크립트 또는 재컴파일 없이 앱 기능을 확장하는 데 적합합니다.
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: