Open momole02 opened 1 year ago
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..
var jsInvokable = engine.evaluate("greet") as JSInvokable;
jsInvokable.invoke(["XXX"]);
JsRef.freeRecursive(jsInvokable);
var jsInvokable = engine.evaluate("(key, value)=>this[key]=value") as JSInvokable;
jsInvokable.invoke([
"add",
(a1, a2){
return a1 + a2;
}
]);
JsRef.freeRecursive(jsInvokable);
add(1,2);
I have made some researches on the library in the API documentation. I have noticed many UNDOCUMENTED methods which involve
contextes: https://pub.dev/documentation/flutter_js/latest/javascriptcore_jscore_js_context/javascriptcore_jscore_js_context-library.html
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.