WASM
flutter_rust_bridge_codegen can also generate code to run in browsers using
wasm_bindgen. To generate a WASM-specific file, pass this option to your invocation:
flutter_rust_bridge_codegen .. --wasm
By default this will create several new files:
âââ lib
â âââ ...
â âââ bridge_generated.io.dart
â âââ bridge_generated.web.dart
âââ native/src
âââ bridge_generated.io.rs
âââ bridge_generated.web.rs
The .io and .web modules implement platform-specific helpers. This
split is mandatory for Dart due to its module system, however if you prefer to keep the Rust bridge in a single file pass the --inline-rust
flag as well.
Check out Integrating with Web for instructions on how to consume the web bridge.
have a look at issue 860