This repository serves as a template for Flutter projects calling into native Rust
libraries via flutter_rust_bridge
.
To begin, ensure that you have a working installation of the following items:
- Flutter SDK
- Rust language
- Appropriate Rust targets for cross-compiling to your device
- For Android targets:
- Install cargo-ndk
- Install Android NDK 22, then put its path in one of the
gradle.properties
, e.g.:
echo "ANDROID_NDK=.." >> ~/.gradle/gradle.properties
This template use just to get things done. You should download it.
It also use flutter_rust_bridge_codegen, so you should have it install on your machine. You can install it with cargo install flutter_rust_bridge_codegen
You also need to make sure that you have llvm install.
You can install it as follow:
- ubuntu/linux
sudo apt-get install libclang-dev
- Windows
winget install -e --id LLVM.LLVM
- MacOs
brew install llvm
- Web dependencies for the Web
Then go ahead and run flutter run
! When you're ready, refer to our documentation
here
to learn how to write and use binding code.
Once you have edited api.rs
to incorporate your own Rust code, the bridge files bridge_definitions.dart
and bridge_generated.dart
are generated using the following command:
If you have already install just
, you can just run just
command line and it will build everythings for you. You can check the detail of what the just
command does in the justfile
. To run a specific task, use just <taskname>
If you would like to generate boilerplate for using flutter_rust_bridge
in your existing projects,
check out the flutter_rust_bridge
brick
for more details.