Is anyone know how to call JS function from dart ? I followed steps which linked below.
Firstly, appear this error.
"Error: Not found: 'dart:js' import 'dart:js';"
I followed previous answer which comment this line from js.dart and fixed it.
[export 'dart:js' show allowInterop, allowInteropCaptureThis;].
But now I got another error below.
No top-level method 'callJsFunc' declared. Receiver: top-level Tried calling: callJsFunc()
Is anyone know how to fix this error ?
I tried other Flutter SDK version (latest one and 3.0.5) but got same error.
CodePudding user response:
flutter
uses dart
not javascript
.
so... actually you require a separate javascript engine
if you want to use javascript
with flutter
and that can be done with dart ffi
unless you are building a web app
with flutter
.
However, there is a library called flutter_js and you can use it if you need to run javascript
.
On the other hand, if you are interested in using embeddable Javascript engine
with your flutter
project by yourself.
you should check this link out where it shows how to use ffi
for attaching an embeddable Javascript engine
called Duktape
CodePudding user response:
Thank you for the advice. I will try to use flutter_js package.
Our teams are developing iOS and Android used by Flutter. Flutter Web is not developing. Those dart:js, js|dart packages can be used for Flutter Web app only?