flutter_quickjs

Last updated:

0 purchases

flutter_quickjs Image
flutter_quickjs Images
Add to Cart

Description:

flutter quickjs

flutter_quickjs #
Flutter bindings with dart:ffi for QuickJS : A small Javascript engine supports ES2020.
This is a plugin help execute javascript on flutter app, which is convenient to use with simple apis, and it supports iOS, Android now.
Install #
To use this plugin, add flutter_quickjs as a dependency in your pubspec.yaml file.
Usage #
Basic Example #
import 'package:flutter/material.dart';
import 'package:flutter_quickjs/flutter_quickjs.dart';

void main() {
var evalResult = runJs();
runApp(
MaterialApp(
home: Material(
child: Center(
child: Text(evalResult),
),
),
),
);
}

runJs() {
var qjs = FlutterQuickjs();
var res = qjs.eval('Math.PI');
qjs.close();
return res.toString();
}
copied to clipboard
Global Object #
qjs.eval('var a = 666;');
print(qjs.global()['a']);
// 666
copied to clipboard
Set Value #
qjs.setValue('globalThis.console.log', (msg) {
print(msg);
});
qjs.eval('console.log("hello world!")');
// hello world!
copied to clipboard
JS Function Call #
var func = qjs.eval('function func(a, b){return [a, b, a + b];}func');
print(func(2,3));
// [2, 3, 5]
copied to clipboard
For more usages please see example
Datatype Mapping #



dart
js




null
Undefined / Null


Bool
Boolean


Int
Number


Double
Number


String
String


List
Array


Map
Object


Function
Function


Exception
Error



Todo #

bytecode support
support more platforms like macos,linux

Reference #

bellard/quickjs
ekibun/flutter_qjs
Pocket4D/quickjs_dart
siuying/QuickJS-iOS

Lincense #
MIT © ZhangPingFan

License:

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.