Web setup
info
This guide was written for flutter_rust_bridge v1, thus some content may be outdated. The quickest approach to integrate is to follow the one-click approach in flutter_rust_bridge's quickstart page.
Building on web requires nightly Rust, the wasm32-unknown-unknown target
and wasm-pack, which can be installed using these commands:
rustup toolchain install nightly
rustup +nightly component add rust-src
rustup +nightly target add wasm32-unknown-unknown
# either of these
curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
cargo install wasm-pack
Optionally (but highly recommended), install flutter_rust_bridge_serve
to expedite the process of building the WASM binary and setting up HTTP headers:
# in your Flutter/Dart package
flutter pub add flutter_rust_bridge
# then run this instead of "flutter web -d chrome"
dart run flutter_rust_bridge:serve
# or install globally
dart pub global activate flutter_rust_bridge
flutter_rust_bridge_serve
Limitations of WASM
Running code on the Web entails several restrictions on the kinds of code that can be executed. Please refer to Limitations of WASM to see if your code is compatible with WASM.