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

Codacy Badge Rust Package Flutter Package CI Example

Logo

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.
  • Type support: Unlike low-level binding generator which only provide primitives and pointers, this package provides things like Vec<u8>(Uint8List), Vec<T>(List<T>), any custom struct(class)s, and even recursive structs (e.g. a tree node).
  • Zero-copy: Pass big array of bytes from Rust to Dart without any memory copies.
  • Async programming: Simply call functions directly in main isolate (thread) of Dart/Flutter, and Rust code will not block the Flutter UI.
  • Easy to use: All you need to do is write down your Rust code. The code generator will do everything and expose an API in Dart/Flutter's style.
  • 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).
  • Easy to code-review & convince yourself: This package simply simulates how human beings write down boilerplate code. If you want to convince yourself (or your team) that it is safe, there is not much code for you to look at. The runtime is only hundreds of loc, and the generated code follows simple patterns. No magic and also no blackbox macros at all! (More about safety concerns.)
  • Pure-Dart compatible: Despite the name, this package is 100% compatible with pure Dart. It does not require anything specific to Flutter. See this pure-Dart example.

💡 User Guide

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

Contributors ✨

All Contributors

Thanks goes to these wonderful people (emoji key):


fzyzcjy

💻 📖 💡 🤔 🚧

Viet Dinh

💻 ⚠️ 📖

Marcel

💻

rustui

📖

Michael Bryan

💻

bus710

📖

Sebastian Urban

💻

Daniel

💻

Kevin Li

💻 📖

Joshua Wade

💻

This project follows the all-contributors specification. Contributions of any kind welcome!