flutter_js icon indicating copy to clipboard operation
flutter_js copied to clipboard

Is evaluate() the ONLY WAY of using this library ??

Open momole02 opened this issue 2 years ago • 2 comments

I have made some researches on the library in the API documentation. I have noticed many UNDOCUMENTED methods which involve

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.

momole02 avatar Mar 12 '23 11:03 momole02

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

ekkis avatar Apr 13 '24 02:04 ekkis

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.

At Last

liruohrh avatar Jul 11 '24 23:07 liruohrh