Running and Building
📱 For Native Platforms
The following commands are just enough to run and build apps for native platforms. It's that simple.1
To run the app:
To build the app for a specific platform:
🌍 For the Web
You need to manually build webassembly module from Rust before running or building the app for the web.2
To serve3 the web application4:
rinf wasm
flutter run --web-header=Cross-Origin-Opener-Policy=same-origin --web-header=Cross-Origin-Embedder-Policy=require-corp
To build the optimized release version of the web application5:
When deploying your web app on a web server, ensure that your web server is configured to include cross-origin-related HTTP headers in its responses. These headers enable web browsers using your website to gain access to SharedArrayBuffer
web API, which is something similar to shared memory on the web.
Cross-Origin-Opener-Policy
:same-origin
Cross-Origin-Embedder-Policy
:require-corp
.
Additionally, don't forget to specify the MIME type application/wasm
for .wasm
files within the server configuration to ensure optimal performance.
-
Rinf builds the native Rust library and links it to the Flutter app using Cargokit. ↩
-
Internally, Rinf uses
wasm-bindgen
andwasm-pack
with theweb
target. ↩ -
Note that Flutter apps in debug mode are known to be quite slow on the web. It is recommended to use profile mode when testing on a web browser. ↩
-
Since repeatedly writing web header arguments during development can be overwhelming, Rinf provides a convenient command
rinf server
that prints the full Flutter web command. ↩ -
Rinf supports hosting a Flutter app at a non-root location. For example, you can place your Flutter app in
https://mywebsite.com/subpath/deeperpath/
. ↩