flutter_rust_bridge v2: Flutter/Dart <-> Rust binding generator, feature-rich, but seamless and simple.

Rust Package Flutter Package Stars CI Post-Release codecov All Contributors Codacy Badge

Logo

What's new in V2

Tap to expand

Please visit this page for more information and update guide.

๐Ÿ€ What's this?

๐Ÿ“š Quickstart

Create a working Flutter + Rust app and see it live, by running:

cargo install flutter_rust_bridge_codegen && flutter_rust_bridge_codegen create my_app && cd my_app && flutter run
Expand optional steps

(Optional) Edit rust/src/api/simple.rs (e.g. Hello -> Hi), then see the change by:

flutter_rust_bridge_codegen generate && flutter run

For more elaborated quickstart, please visit this page.

๐Ÿš€ Advantages

1. Officially Flutter Favorite

This package is officially Flutter Favorite, and is in the first batch of 7 packages at its rebooting. (another link)

2. Simplicity

(Tap to expand) Rapid setup, Write your code naturally, Use libraries/tools in Flutter/Rust, Battery included

3. Powerfulness

(Tap to expand) Arbitrary types, Async & sync, Two-way road, Auto-translatable types, Parsing third-party packages, Auto safety, Customizable & bare-metal mode, Cross-platform, ...

4. Reliability

(Tap to expand) Solid CI, Used by many people, Easy to review, Fast, Hackable, Ask questions

Why Flutter + Rust?

Tap to expand

Firstly, super briefly introduce each component (you can find much more in a lot of blogs and posts):

Typical scenarios to combine them include:

โœจ Show me the code

Example 1

Simple Rust...

fn f(a: String, b: Vec<MyEnum>) -> MyStruct { ... }

...called from Dart, without manual intervention.

print(f(a: 'Hello', b: [MyEnum.c('Tom')]));

Example 2

Suppose we implement a word dictionary in Rust:

// โ†ฑ Arbitrarily fancy Rust types
pub struct WordDict { .. }

// โ†ฑ Support functions & methods
impl WordDict {
    //          โ†ฑ Can call Dart back                 โ†ฑ Translate errors
    pub fn open(chooser: impl Fn(String) -> bool) -> Result<WordDict> { .. }

    // โ†ฑ Support async & sync Dart; property getter
    #[frb(sync, getter)]
    //          โ†ฑ Support T/&T/&mut T
    pub fn size(&self) -> u32 { .. }

    //  โ†ฑ Allow async & sync                    โ†ฑ Support stream (iterator)
    pub async fn search(&self, keyword: String, sink: StreamSink<String>) { .. }
}

Still seamlessly call in Dart:

final dict = await WordDict.open((situation) => true);
print(dict.size);
await for (final value in dict.search('something')) { print(value); }

There are still many features not covered here, such as parsing third party packages, lifetimes, traits, auto accessors, proxies, etc.

๐Ÿ’ก Documentation

Check out the documentation for quickstart, full guides and more.

๐Ÿ“Ž P.S. Achieve ~60 FPS, no matter how janky the Flutter app was due to build/layout

Here is my other open-source library :) https://github.com/fzyzcjy/flutter_smooth.

โœจ Acknowledgments and contributors

Firstly, I want to sincerely thank Dart, Flutter and Rust (alphabetical order). Dart provides a solid foundation for productive UI development, Flutter enables developers to make cross-platform apps with ease, and Rust empowers everyone to build reliable and efficient software. Without the languages and frameworks, this bridge connects absolutely nothing. Besides, I also want to express my thanks for conferring the official Flutter Favorite honor to the package. In addition, I also want to say thanks to the Dart, Flutter and Rust team members as well as community members, who have helped me during the development of flutter_rust_bridge by valuable discussions, insights, and actions.

Secondly, thanks goes to these wonderful contributors (emoji key following all-contributors specification):

fzyzcjy
fzyzcjy

๐Ÿ’ป ๐Ÿ“– ๐Ÿ’ก ๐Ÿค” ๐Ÿšง
Viet Dinh
Viet Dinh

๐Ÿ’ป โš ๏ธ ๐Ÿ“–
rogurotus
rogurotus

๐Ÿ’ป ๐Ÿ“–
Nicolas Gasull
Nicolas Gasull

๐Ÿ’ป
Joshua Wade
Joshua Wade

๐Ÿ’ป
Lattice 0
Lattice 0

๐Ÿ’ป ๐Ÿ“–
Unoqwy
Unoqwy

๐Ÿ’ป
Anton Lazarev
Anton Lazarev

๐Ÿ’ป
sagu
sagu

๐Ÿ’ป ๐Ÿ“–
Sebastian Urban
Sebastian Urban

๐Ÿ’ป
Rom's
Rom's

๐Ÿ’ป ๐Ÿ“–
่€่‘ฃ
่€่‘ฃ

๐Ÿ’ป ๐Ÿ“–
Gregory Conrad
Gregory Conrad

๐Ÿ“– ๐Ÿ’ป
huang12zheng
huang12zheng

๐Ÿ’ป ๐Ÿ“–
Daniel
Daniel

๐Ÿ’ป
Manuel Philipp
Manuel Philipp

๐Ÿ’ป ๐Ÿ“–
SoLongAnd...
SoLongAnd...

๐Ÿ’ป ๐Ÿ“–
hsfzxjy
hsfzxjy

๐Ÿ’ป
Cupnfish
Cupnfish

๐Ÿ’ป
alanlzhang
alanlzhang

๐Ÿ’ป ๐Ÿ“–
Erikas Taroza
Erikas Taroza

๐Ÿ’ป
่˜่˜
่˜่˜

๐Ÿ’ป
SimplyKyle!
SimplyKyle!

๐Ÿ’ป
Zaitam
Zaitam

๐Ÿ’ป
Brent Lewis
Brent Lewis

๐Ÿ’ป ๐Ÿ“–
derdilla
derdilla

๐Ÿ’ป ๐Ÿ“–
nitn3lav
nitn3lav

๐Ÿ’ป ๐Ÿ“–
Henry
Henry

๐Ÿ’ป
Kevin Li
Kevin Li

๐Ÿ’ป ๐Ÿ“–
Alex Procelewski
Alex Procelewski

๐Ÿ“– ๐Ÿ’ป
Larpoux
Larpoux

๐Ÿ’ป
Patrick Mukherjee
Patrick Mukherjee

๐Ÿ’ป
Daniel Porteous (dport)
Daniel Porteous (dport)

๐Ÿ“–
Alex Li
Alex Li

๐Ÿ’ป
Integral
Integral

๐Ÿ’ป
Tien Do Nam
Tien Do Nam

๐Ÿ’ป
Satvik Pendem
Satvik Pendem

๐Ÿ’ป
Andreas Monitzer
Andreas Monitzer

๐Ÿ’ป
Kim Dong-Hyun
Kim Dong-Hyun

๐Ÿ’ป ๐Ÿ“–
NightFeather
NightFeather

๐Ÿ’ป
Alex Ballmer
Alex Ballmer

๐Ÿ’ป
alexlapa
alexlapa

๐Ÿ’ป
Wei Xu
Wei Xu

๐Ÿ’ป
Josรฉ Carlos
Josรฉ Carlos

๐Ÿ’ป
ไนๆœˆ
ไนๆœˆ

๐Ÿ’ป
Jippe Holwerda
Jippe Holwerda

๐Ÿ’ป
Salvatore Pelligra
Salvatore Pelligra

๐Ÿ’ป
wxitcode
wxitcode

๐Ÿ“–
Arjen
Arjen

๐Ÿ’ป
evdokimovs
evdokimovs

๐Ÿ’ป
Johannes Lรถthberg
Johannes Lรถthberg

๐Ÿ’ป
Markus
Markus

๐Ÿ’ป
Krysl
Krysl

๐Ÿ’ป
Frederick Vollbrecht
Frederick Vollbrecht

๐Ÿ’ป
Wouter Ensink
Wouter Ensink

๐Ÿ“–
Marcel
Marcel

๐Ÿ’ป
Aidan
Aidan

๐Ÿ“–
Debanjan Basu
Debanjan Basu

๐Ÿ“–
Patrick Auernig
Patrick Auernig

๐Ÿ’ป
Sai Chaitanya
Sai Chaitanya

๐Ÿ’ป
Xidorn Quan
Xidorn Quan

๐Ÿ’ป
jsonmona
jsonmona

๐Ÿ’ป
mtz
mtz

๐Ÿ’ป
codercengiz
codercengiz

๐Ÿ’ป
Aran Donohue
Aran Donohue

๐Ÿ’ป
Michael Bryan
Michael Bryan

๐Ÿ’ป
Philip Kannegaard Hayes
Philip Kannegaard Hayes

๐Ÿ’ป
SilverMira
SilverMira

๐Ÿ’ป
Sander in 't Hout
Sander in 't Hout

๐Ÿ’ป
Haled Odat
Haled Odat

๐Ÿ’ป
็Ž‹ๅฎ‡้€ธ
็Ž‹ๅฎ‡้€ธ

๐Ÿ’ป
bus710
bus710

๐Ÿ“–
._.
._.

๐Ÿ“–
Marc Gutenberger
Marc Gutenberger

๐Ÿ’ป
Andrii Stadnik
Andrii Stadnik

๐Ÿ’ป
syndim
syndim

๐Ÿ’ป
Dirk Van Haerenborgh
Dirk Van Haerenborgh

๐Ÿ’ป
Karthik K
Karthik K

๐Ÿ“–
Rhian Moraes
Rhian Moraes

๐Ÿ“–
Ares Andrew
Ares Andrew

๐Ÿ“–
Connor J Buchel
Connor J Buchel

๐Ÿ’ป ๐Ÿ“–
polypixeldev
polypixeldev

๐Ÿ“–
CicadaCinema
CicadaCinema

๐Ÿ’ป ๐Ÿ“–
CosmicHorror
CosmicHorror

๐Ÿ’ป
Akash Gurava
Akash Gurava

๐Ÿ’ป
Fabian Lรถschner
Fabian Lรถschner

๐Ÿ’ป
Vincent Herlemont
Vincent Herlemont

๐Ÿ’ป
canxin
canxin

๐Ÿ’ป
pixelshot91
pixelshot91

๐Ÿ“–
TrackerSB
TrackerSB

๐Ÿ’ป
Slavik Bubnov
Slavik Bubnov

๐Ÿ“–
Dampfwalze
Dampfwalze

๐Ÿ“–
Samuel Cavalcanti
Samuel Cavalcanti

๐Ÿ“–
Roman Zaynetdinov
Roman Zaynetdinov

๐Ÿ“–
raphaelrobert
raphaelrobert

๐Ÿ“–
Mouayad Alhamwi
Mouayad Alhamwi

๐Ÿ“–
elliotsayes
elliotsayes

๐Ÿ“–
muji
muji

๐Ÿ“–
thomas725
thomas725

๐Ÿ“–
orange soeur
orange soeur

๐Ÿ“–
Alex Gorichev
Alex Gorichev

๐Ÿ“–
Sven-Hendrik Haase
Sven-Hendrik Haase

๐Ÿ“–
Chris Ohk
Chris Ohk

๐Ÿ“–
Vitalii Hurianov
Vitalii Hurianov

๐Ÿ“–
Sam Nystrom
Sam Nystrom

๐Ÿ“–
mattiasgronlund
mattiasgronlund

๐Ÿ’ป
Antonio D'souza
Antonio D'souza

๐Ÿ“–
max
max

๐Ÿ“–
Jonathan
Jonathan

๐Ÿ“–
Akash Jaiswal
Akash Jaiswal

๐Ÿ“–
Febrian Setianto
Febrian Setianto

๐Ÿ“–
Adam Huganir
Adam Huganir

๐Ÿ“–
Ernest M. van der Linden
Ernest M. van der Linden

๐Ÿ“–
Damien Wise
Damien Wise

๐Ÿ“–
rustui
rustui

๐Ÿ“–
J
J

๐Ÿ“–
Ikko Ashimine
Ikko Ashimine

๐Ÿ“–
thesimplekid
thesimplekid

๐Ÿ“–

More specifically, thanks for all these contributions:

Join libs.tech

...and unlock some superpowers

GitHub

We won't share your data with anyone else.