native_toolchain_rust
1.1.1, released 6 days ago by gsconrad.com
Build and bundle Rust code into a Dart/Flutter project via build hooks.
What it does
It automates compiling Rust libraries for all supported platforms and packages the binaries as assets that Dart can load. The only required input is the asset name; the rest is inferred from Cargo.toml and rust-toolchain.toml.
AI-written summary of version 1.0.7, based on the package's README and metadata. Report an inaccuracy
Use it when
- You need native performance or system libraries written in Rust.
- You want reproducible builds across Android, iOS, Windows, macOS, and Linux.
- You prefer a declarative build setup over manual Cargo commands.
Skip it when
- You only target a single platform and prefer manual Cargo integration.
- You need fine‑grained control over the Rust build process beyond what the hook offers.
Strengths
- Zero‑config Rust integration after initial Cargo setup.
- Cross‑platform builds with a single command.
- Automatic dependency discovery and rebuild triggers.
- Supports both staticlib and cdylib targets.
Weaknesses
- Requires rustup and a Rust toolchain on the developer machine.
- Limited to the platforms listed; adding new targets needs code changes.
Setup
- Kind
- Pure Dart
- Effort
- Medium
- Code generation
- No
- Direct dependencies
- 6
Add rustup, create Cargo.toml and rust-toolchain.toml, run flutter pub add native_toolchain_rust hooks, then add a build.dart hook that calls RustBuilder.
```dart
import 'package:hooks/hooks.dart';
import 'package:native_toolchain_rust/native_toolchain_rust.dart';
void main(List<String> args) async {
await build(args, (input, output) async {
await RustBuilder(assetName: 'src/my_ffi_bindings.g.dart').run(input: input, output: output);
});
}
```Alternatives
Packages that do the same job and could replace native_toolchain_rust.
- flutterflow_cli
Command-line client for FlutterFlow to export code and build apps with AI.
76Compare - flutter_gpu_shaders
Build tool that compiles Flutter GPU shader bundles via a build hook.
69Compare - change_app_package_name
Rename Flutter app's Android and iOS package identifiers via a single CLI command.
57Compare - git_stamp
Embeds Git commit, branch, and build metadata into Flutter apps with optional UI screens.
57Compare
Works with
Packages commonly used together with native_toolchain_rust: ones it builds on, ones built on it, and its own family.
- hooksnative_toolchain_rust depends on itDart API for the JSON-based protocol for package build and link hooks.
- code_assetsnative_toolchain_rust depends on itProvides the hook protocol specification for bundling native code with Dart packages.
- loggingnative_toolchain_rust depends on itProvides configurable logging with levels and stream listeners for Dart apps.
- tomlnative_toolchain_rust depends on itParse and encode TOML configuration files in Dart.
- velopack_flutterBuilt on native_toolchain_rustCross-platform installation and auto-update framework for desktop apps
- ndkBuilt on native_toolchain_rustDart library for building Nostr clients with relay discovery, caching and signing support.
- pixerBuilt on native_toolchain_rustHigh-performance Dart image manipulation backed by Rust FFI for resizing, cropping, and encoding.
- mimirBuilt on native_toolchain_rustEmbeddable NoSQL database with typo-tolerant full-text search.