This should be simple, but I just can't seem to wrap my head around it.
So I have my dartFile.dart and then I have my javaScriptFile.js. How do I link these two so that I can call JavaScript functions declared in my javaScriptFile.js from my dartFile.dart?
I tried to follow the explanation provided in this post, but I guess it was too vague for me :/
Edit: Here's what I tried:
In my javaScriptFile.js, there is nothing but this simple function:
function myFunction() {
return 4;
}
In my dartFile.dart, there is only this blob of code:
import 'package:js/js.dart' as js;
void main() {
print(js.context.myFunction());
}
Following the instructions in the post I mentioned, I added dependencies for js in the pubspec.yaml file. Basically I'm exactly where the asker of the original question was - I can call basic JavaScript functions like alert, but wehn I try to call my function declared in the javaScriptFile.js, I get a 'NoSuchMethodError'