flutter_rust_bridge 1.19.0 flutter_rust_bridge: ^1.19.0 copied to clipboard
High-level memory-safe binding generator for Flutter/Dart <-> Rust
flutter_rust_bridge: High-level memory-safe binding generator for Flutter/Dart <-> Rust #
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.
- Rich types: Unlike low-level binding generator which only provide primitives and pointers, this package provides things like platform-optimized
Vec<T>
, possibly recursivestruct
,enum
s even with values, error (Result
) handling, andStream
s. - 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.)
- Fast: It is only a thin (though feature-rich) wrapper, no overhead such as protobuf serialization, thus performant. (More benchmarks later) (Throw away components like thread-pool to make it even faster)
- Multi-platform: Android, iOS, Windows, Linux, MacOS (Web coming soon)
- Pure-Dart compatible: Despite the name, this package is 100% compatible with pure Dart. It does not require anything specific to Flutter.
💡 User Guide #
Check out the user guide for show-me-the-code, tutorials, features and much more.
Contributors ✨ #
Thanks goes to these wonderful people (emoji key):
fzyzcjy 💻 📖 💡 🤔 🚧 |
Viet Dinh 💻 ⚠️ 📖 |
Joshua Wade 💻 |
Marcel 💻 |
rustui 📖 |
Michael Bryan 💻 |
bus710 📖 |
Sebastian Urban 💻 |
Daniel 💻 |
Kevin Li 💻 📖 |
Patrick Auernig 💻 |
Anton Lazarev 💻 |
This project follows the all-contributors specification. Contributions of any kind welcome!