A quick and dirty demo on how to use a JavaScript library with Flutter Web
tonejs_meets_flutterweb (Please use Google Chrome)
- Add the JavaScript to your web/index.html
(In this case tone.js)
...
<body>
<script src="https://cdnjs.cloudflare.com/ajax/libs/tone/14.4.9/Tone.js" type="application/javascript"></script>
<script src="main.dart.js" type="application/javascript"></script>
<script>
function playNote(note, duration) {
var synth = new Tone.Synth().toDestination();
synth.triggerAttackRelease(note, duration);
}
</script>
</body>
...
- Call your JavaScript in Dart
import 'dart:js' as js;
...
js.context.callMethod("playNote", ["C5", "8n"])
Easy!