Next, we need to install a few build-time and runtime dependencies.
These dependencies are required only in build-time:
flutter_rust_bridge_codegen, the core codegen for Rust-Dart glue code
ffigen, to generate Dart code from C headers
- A working installation of LLVM, see Installing LLVM, used by
cargo-xcode, if you want to generate Xcode projects for iOS and MacOS
An easy way to install most of these dependencies is to run:
cargo install flutter_rust_bridge_codegen dart pub add --dev ffigen && dart pub add ffi # if building for iOS or MacOS cargo install cargo-xcode
cargo install flutter_rust_bridge_codegen flutter pub add --dev ffigen && flutter pub add ffi # if building for iOS or MacOS cargo install cargo-xcode
Alternatively, each of these dependencies may provide prebuilt binaries. Check with your package manager and review them individually.
On the Dart side,
flutter_rust_bridge is the required runtime component of
flutter_rust_bridge_codegen. If you plan to use enum structs in Rust, the
following dependencies are also needed:
Their usage is explained in Using
flutter pub add flutter_rust_bridge # if using Dart codegen flutter pub add -d build_runner flutter pub add -d freezed flutter pub add freezed_annotation
Similar to Dart, Rust requires the
flutter_rust_bridge runtime component for support.
Add these lines to
+[dependencies] +flutter_rust_bridge = "1"