Is evaluate() the ONLY WAY of using this library ??
I have made some researches on the library in the API documentation. I have noticed many UNDOCUMENTED methods which involve
-
dynamic objects: https://pub.dev/documentation/flutter_js/latest/javascriptcore_jscore_js_object/JSObject-class.html
-
... and many interesting things for DART and JS INTEROPERABILITY , called dartContext, localContext, and callFunction() right here : https://pub.dev/documentation/flutter_js/latest/javascript_runtime/JavascriptRuntime-class.html but NOT DOCUMENTED.
I don't understand why those classes and methods aren't used in the OFFICIAL EXAMPLES of the libraires, Instead we got only the usage of evaluate() which I think is too limited, and USELESS for me.
- How can I execute dart function in the JS code ?
- How can I pass variables to the JS code ?
- How can I provide an API FOR THE JAVASCRIPT CODE used in the flutter project ??
If you can't provide good examples of using your libraries then document them, and if the only thing your library can do is evaluate() it's pretty disappointing.
I've been researching the interoperability between Flutter and Javascript. it's poor at best, it would seem, and I may have to dump Flutter, sadly abandoning what I've built so far for React Native
for QuickJs, I tested it for a long time the interoperability between Flutter and Javascript.. #Dart call JS
var jsInvokable = engine.evaluate("greet") as JSInvokable;
jsInvokable.invoke(["XXX"]);
JsRef.freeRecursive(jsInvokable);
Js call Dart
var jsInvokable = engine.evaluate("(key, value)=>this[key]=value") as JSInvokable;
jsInvokable.invoke([
"add",
(a1, a2){
return a1 + a2;
}
]);
JsRef.freeRecursive(jsInvokable);
- js
add(1,2);
Proxy Object
- in js, use Proxy API
- for function should call by convention
- for Proxy only proxy get property, js function is also a property of object, can't proxy object function calling.
- such $xxx is call js DartObject function, $$xxx is call JsObject function.
- for function should call by convention
At Last
- in dart, I find reflect lib of reflectable is great, although reflectable is just good for static reflect.
- you can reference my test.