#flutter #gui-framework #cross-platform #dart #native #business #flexible

bin+lib rinf

Rust for native business logic, Flutter for flexible and beautiful GUI

45 stable releases

6.7.0 Mar 15, 2024
6.6.3 Mar 12, 2024
6.6.2 Feb 29, 2024
6.2.0 Jan 30, 2024
4.14.0 Oct 25, 2023

#43 in GUI

Download history 74/week @ 2024-01-02 326/week @ 2024-01-09 6967/week @ 2024-01-16 12648/week @ 2024-01-23 13096/week @ 2024-01-30 13164/week @ 2024-02-06 13289/week @ 2024-02-13 13082/week @ 2024-02-20 12890/week @ 2024-02-27 13376/week @ 2024-03-05 13419/week @ 2024-03-12 14088/week @ 2024-03-19 14103/week @ 2024-03-26 13070/week @ 2024-04-02 11430/week @ 2024-04-09 11130/week @ 2024-04-16

52,079 downloads per month

MIT license

21KB
273 lines

Rinf: Rust in Flutter

Pub Version Crate Version GitHub Stars Build Test GitHub License

Rust for native business logic, Flutter for flexible and beautiful GUI

Preview

Rinf is a production-ready framework for creating beautiful and performant cross-platform apps using Flutter and Rust with batteries fully included. Simply add this framework to your app project, and you're all set to write Flutter and Rust together!

🎮 Demo

Visit the demo running on the web to experience the smoothness and delightfulness that comes from the combination of Flutter and Rust. You can also dive into the example code.

🖥️ Platform Support

All platforms available with Flutter are tested and supported. Challenging build settings are automatically handled by this framework.

  • ✅ Linux: Tested and supported
  • ✅ Android: Tested and supported
  • ✅ Windows: Tested and supported
  • ✅ macOS: Tested and supported
  • ✅ iOS: Tested and supported
  • ✅ Web: Tested and supported

📞 Communication

Below is Dart code with widgets, and following that is Rust code with business logic.

MySchemaInput(
  fieldOne: 1,
  fieldTwo: 2,
  fieldThree: 3,
).sendSignalToRust(null)

final stream = MySchemaOutput.rustSignalStream;
await for (final rustSignal in stream) {
  // Custom Dart logic
}
MySchemaOutput {
    field_four: 4,
    field_five: 5,
    field_six: 6,
}.send_signal_to_dart(None)

let mut receiver = MySchemaInput::get_dart_signal_receiver();
while let Some(dart_signal) = receiver.recv().await {
    // Custom Rust logic
}

All the message classes and structs are generated by Rinf. You can simply define the message schema with Protobuf. Sending messages between Dart and Rust is very convenient.

🎁 Benefits

  • Truly easy: It only takes about about a minute or two to fully setup your app.
  • Efficient: All communication occurs solely through native FFI. There are no webviews, web servers, hidden threads, or unnecessary memory copying that might cause performance overhead. This setup acts as a very thin wrapper around Dart and Rust.
  • Minimal: This is not a bulky framework that requires you to install so many dependencies and use complicated CLI commands. Just focus on your code using your preferred Flutter and Rust libraries.
  • Scalable: Creating hundreds or even thousands of message APIs between Dart and Rust feels smooth and clean. Additionally, you have the flexibility to utilize any number of Rust library crates, perhaps including those you might have been working on.
  • High-level interface: No messing with sensitive build files, no concerns about memory safety. Stay with Dart and Rust that you're familiar with.
  • Well maintained: Our automated workflows including build tests are always kept passing, thanks to the main branch protection rule. Also, the number of external dependencies is kept as low as possible and documentations are thoughtfully organized.
  • Convenient debugging: All the debugging functionalities are provided by default, without the need for dealing with browsers or mobile emulators. Also, the whole Rust logic is automatically restarted on Dart's hot restart.
  • Reliable: Each component is supported by huge communities, ensuring a strong emphasis on future safety. You can easily assure your team of stability since this framework's underlying concept is fairly simple.

🐦 Why Use Flutter?

While Rust is a powerful language for high-performance native programming, its ecosystem for building graphical user interfaces is far from being mature. Though Rust already has some GUI frameworks, they don't compete with extensive support and smooth development experience that Flutter provides. It's only Flutter that compiles to all 6 major platforms from a single codebase.

Flutter is a powerful and versatile framework that has gained immense popularity for building cross-platform applications with stunning user interfaces. It provides declarative pattern, beautiful widgets, hot reload, convenient debugging tools, and dedicated packages for user interfaces right out-of-the-box.

🦀 Why Use Rust?

While Dart excels as an amazing object-oriented language for GUI apps, its non-native garbage collection may not always meet demanding performance requirements, and it may lack advanced data manipulation packages. This is where Rust steps in, offering an incredible speed advantage of roughly 2~40 times faster than Dart, alongside the ability to leverage multiple threads and various crates that get the job done.

Rust has garnered a devoted following, being the most loved programming language on Stack Overflow. Its native performance, thanks to the zero-cost abstraction philosophy, ensures high productivity. Many developers foresee Rust potentially replacing C++ in the future. Rust's simplicity, memory safety, superior performance in various scenarios, vibrant community, and robust tooling support contribute to its growing popularity.

📖 Documentation

Check out the documentation for everything you need to know about how to use this thing.

👥 Contribution

If Rinf has been helpful, please consider giving a star to our GitHub repository and a like to our Pub package. You can also support us by spreading the word and sharing this framework online.

We appreciate your contribution to the development of this project! We're always open to discussions and pull requests, so please do not hesitate to leave your ideas or opinions at our GitHub repository.

GitHub contributors

Dependencies

~0–12MB
~147K SLoC