calling javascript from Dart

后端 未结 2 1945
无人及你
无人及你 2020-12-09 11:23

i was able to fire off an alert message from dart, but couldn\'t figure out how to call a function I wrote in another js file from dart. This would have been a great sellin

2条回答
  •  误落风尘
    2020-12-09 11:40

    Maybe my answer will be worth it for somebody, so that's why I'm posting a simple JS function call from Dart.

    1. Add the js package dependency:
      dependencies:
        js: any
      
    2. Create a JS file, let's say example.js:
      function test() {
        return 12+20;
      }
      
    3. Add the example.js above inside index.html with the
提交回复
热议问题