#flutter #dart #ffi #code-generation #bindings


High-level memory-safe binding generator for Flutter/Dart <-> Rust

48 stable releases

1.30.0 May 12, 2022
1.28.1 Apr 30, 2022
1.23.0 Mar 16, 2022
1.10.0 Dec 30, 2021
1.8.0 Nov 27, 2021

#60 in FFI

Download history 1117/week @ 2022-01-29 1203/week @ 2022-02-05 1156/week @ 2022-02-12 1883/week @ 2022-02-19 1838/week @ 2022-02-26 1753/week @ 2022-03-05 1897/week @ 2022-03-12 2111/week @ 2022-03-19 2036/week @ 2022-03-26 2019/week @ 2022-04-02 2108/week @ 2022-04-09 2111/week @ 2022-04-16 2562/week @ 2022-04-23 3981/week @ 2022-04-30 4068/week @ 2022-05-07 4520/week @ 2022-05-14

15,457 downloads per month

MIT license

346 lines

flutter_rust_bridge: High-level memory-safe binding generator for Flutter/Dart <-> Rust

Rust Package Flutter Package Stars CI Example Codacy Badge


Want to combine the best between Flutter, a cross-platform hot-reload rapid-development UI toolkit, and Rust, a language empowering everyone to build reliable and efficient software? Here it comes!

🚀 Advantages

  • Memory-safe: Never need to think about malloc/free.
  • Feature-rich: enums with values, platform-optimized Vec, possibly recursive struct, zero-copy big arrays, Stream (iterator) abstraction, error (Result) handling, cancellable tasks, concurrency control, and more. See full features here.
  • Async programming: Rust code will never block the Flutter. Call Rust naturally from Flutter's main isolate (thread).
  • Lightweight: This is not a huge framework that includes everything, so you are free to use your favorite Flutter and Rust libraries. For example, state-management with Flutter library (e.g. MobX) can be elegant and simple (contrary to implementing in Rust); implementing a photo manipulation algorithm in Rust will be fast and safe (countrary to implementing in Flutter).
  • Cross-platform: Android, iOS, Windows, Linux, MacOS (Web coming soon)
  • Easy to code-review & convince yourself: This package simply simulates how humans write boilerplate code. If you want to convince yourself (or your team) that it is safe, there is not much code to look at. No magic at all! (More about safety concerns.)
  • Fast: It is only a thin (though feature-rich) wrapper, without overhead such as protobuf serialization, thus performant. (More benchmarks later) (Throw away components like thread-pool to make it even faster)
  • Pure-Dart compatible: Despite the name, this package is 100% compatible with pure Dart.

💡 User Guide

Check out the user guide for show-me-the-code, tutorials, features and much more.

📎 P.S. Convenient Flutter tests

If you want to write and debug tests in Flutter conveniently, with action history, time travelling, screenshots, rapid re-execution, video recordings, interactive mode and more, here is my another open-source library: https://github.com/fzyzcjy/flutter_convenient_test.

✨ Contributors

All Contributors

Thanks goes to these wonderful people (emoji key following all-contributors specification):


💻 📖 💡 🤔 🚧

Viet Dinh

💻 ⚠️ 📖

Joshua Wade






Michael Bryan




Sebastian Urban




Kevin Li

💻 📖

Patrick Auernig


Anton Lazarev




Febrian Setianto





💻 📖

More specifically, thanks for all these contributions:

  • Desdaemon: Support not only simple enums but also enums with fields which gets translated to native enum or freezed class in Dart. Support the Option type as nullable types in Dart. Support Vec of Strings type. Support comments in code. Add marker attributes for future usage. Add Linux and Windows support for with-flutter example, and make CI works for that. Avoid parameter collision. Overhaul the documentation and add several chapters to demonstrate configuring a Flutter+Rust project in all five platforms. Refactor command module.
  • SecondFlight: Allow structs and enums to be imported from other files within the crate by creating source graph. Auto-create relavent dir.
  • Unoqwy: Add struct mirrors, such that types in the external crates can be imported and used without redefining and copying.
  • antonok-edm: Avoid converting syn types to strings before parsing to improve code and be more robust.
  • sagudev: Make code generator a lib. Add error types. Depend on cbindgen. Fix LLVM paths. Update deps. Fix CI.
  • surban: Support unit return type. Skip unresolvable modules. Ignore prefer_const_constructors. Non-final Dart fields.
  • AlienKevin: Add flutter example for macOS. Add doc for Android NDK bug.
  • trobanga: Add support for [T;N]. Add usize support. Add a cmd argument.
  • efc-mw: Improve Windows encoding handling.
  • valeth: Rename callFfi's port.
  • Michael-F-Bryan: Detect broken bindings.
  • bus710: Add a case in troubleshooting.
  • Syndim: Add a bracket to box.
  • feber: Fix doc link.
  • rustui: Fix a typo.


~94K SLoC