Call Rust code from Flutter and Dart, with the glue code generated for you
open sourceMITfree
flutter_rust_bridge is a binding generator between Flutter/Dart and Rust: you write ordinary Rust, with arbitrary types, closures, &mut, async functions and traits, and call it from Flutter as if it were Dart, while its code generator writes the glue in between. Rust can also call Dart functions. Version 2 sets up a project with one command (flutter_rust_bridge_codegen create), can scan existing Rust packages, and adds a faster SSE codec. It works on Android, iOS, Windows, Linux, macOS and the web (JavaScript and WebAssembly), and is an official Flutter Favorite package.
Problems it solves
- call my Rust library from a Flutter app without writing FFI glue by hand
- move heavy computation in my Flutter app into Rust
- share one Rust core between Flutter apps on mobile, desktop and web
Features
- generates Dart bindings for ordinary Rust code
- arbitrary Rust types, closures, async functions and traits
- Rust can call Dart functions
- one-command project setup with flutter_rust_bridge_codegen create
- Android, iOS, Windows, Linux, macOS and web (JS and WebAssembly)
Alternatives
The same job
These do what flutter_rust_bridge does.
- bindgen Generates Rust FFI bindings to C and some C++ libraries from their headers
- ffi Utilities and a binding generator for calling C from Dart through FFI
- Rustler Write Erlang and Elixir NIFs in safe Rust
- napi-rs A framework for building compiled Node.js add-ons in Rust via Node-API
- wasm-bindgen Generates the glue between Rust WebAssembly modules and JavaScript
- PyO3 Rust bindings for Python: write Python extensions in Rust or embed Python
