How to include a WebAssembly module in a Flutter Web application? #48122
Labels
c: new feature
Nothing broken; request for a new capability
c: proposal
A detailed proposal for a change to Flutter
d: stackoverflow
Good question for Stack Overflow
framework
flutter/packages/flutter repository. See also f: labels.
platform-web
Web applications specifically
would be a good package
Separate Flutter package should be made for this
Milestone
Note: This is shamelessly copied from https://stackoverflow.com/questions/59568536/how-to-include-a-webassembly-module-in-a-flutter-web-application because I think this is a bug/is missing documentation.
I'm trying to extend my Flutter Web application with some Rust code via WebAssembly. My project structure looks like this:
The Rust code just creates a
String
and returns it:When compiled with
wasm-pack build
the bytecode ends up inweb/wasm_demo/pkg/wasm_demo_bg.wasm
.wasm_demo.js
is just a JavaScript module exporting theget_string
function fromwasm_demo_bg.wasm
:bootstrap.js
imports that module and puts it into thewindow
object:index.html
loads that bootstrapper prior to launching the actual application:And finally, Flutter displays the Rust
String
:The problem I have is that
wasm_demo_bg.wasm
is apparently not included in the bundle:Is there any way to tell Flutter that the WebAssembly module is needed in the bundle? Thanks!
Steps to Reproduce
Target Platform: Web
Target OS version/browser: Google Chrome Version 78.0.3904.70
Devices: --
logs
The text was updated successfully, but these errors were encountered: