I need execute part of JS code and give output back to Dart code.
I try use flutter_js: ^0.5.0+6 and it is working in iOS/Android, but I can't compile web project.
How I can execute code like this?
String jsResult = javascriptRuntime.evaluate("""
if (typeof MyClass == 'undefined') {
var MyClass = class {
constructor(id) {
this.id = id;
}
getId() {
return this.id;
}
}
}
var obj = new MyClass(1);
var jsonStringified = JSON.stringify(obj);
var value = Math.trunc(Math.random() * 100).toString();
JSON.stringify({ "object": jsonStringified, "expression": value});
""").stringResult;
(this is sample code from flutter_js: https://pub.dev/packages/flutter_js/example )
I need build app for iOS/Android/Web. Actually working on Flutter 2.10.3.