How to use NodeJS package in Flutter web app

910

You can connect to javascript from flutter web. Best way is to use dart:js library.

Add your custom js file to web directory a make sure that it's loaded

<head>
    <script src="your.js" defer></script>
</head>

For example

function info(text) {
    alert(text)
}

Calling from dart:

import 'dart:js' as js;

js.context.callMethod('info', ['Hello!']);
Share:
910
JakesMD
Author by

JakesMD

Updated on December 01, 2022

Comments

  • JakesMD
    JakesMD 11 months

    I have a Flutter web app that needs to be able to create a virtual midi device. For this, the only option seems to be to use the easymidi NodeJS package. What is the best way of connecting a NodeJS script to a flutter app?