fzyzcjy / flutter_rust_bridge

Flutter/Dart <-> Rust binding generator, feature-rich, but seamless and simple.
https://fzyzcjy.github.io/flutter_rust_bridge/
MIT License
4.25k stars 294 forks source link

Ability to modularize the rust code (and remove dependency on `mod.rs`?) #2380

Open skamansam opened 3 hours ago

skamansam commented 3 hours ago

Is your feature request related to a problem? Please describe. I have an app where I have a full API in rust and a bunch of widgets I want to use in the flutter app. My directory is such:

rust ├── Cargo.lock ├── Cargo.toml └── src ├── api │ ├── mod.rs │ ├── rectangles │ │ └── widgets.rs │ ├── rectangles.rs │ ├── my_company │ │ └── api │ │ ├── sample_doc_pic.png │ │ └── simple.rs │ │ └── full.rs │ ├── my_company.rs │ └── simple.rs ├── frb_generated.rs └── lib.rs

Where the my_company module holds two different apis, and rectangles holds a bunch of iced widgets. NOTE: According to the rust docs, mod.rs is deprecated, and one should use the <module>.rs syntax going forward. Here is the makeup of my modules:

file: rust/src/api/mod.rs

pub mod my_comapny;
pub mod rectangles;
mod frb_generated;

file: rust/src/api/my_company.rs

pub mod api;

file: rectangels.rs

pub mod widgets;

file:

use my_company::api::simple;
use rectangles::widgets;

#[derive(Widget)]
pub RectanglesWidget = widgets::RectanglesWidget;

pub api = simple;

Describe the solution you'd like I would like this to generate two files: lib/src/rust/api/my_company/api/simple.dart and lib/src/rust/api/my_company/rectangles.dart and do all the necessary bindings for bopth of them. Currently, I can only get the first one built.

Describe alternatives you've considered I have tried all manner of adding the last one to the project, including what your documentation says to do by adding it to a list in the config yaml:

rust_input: crate::api,crate::api::my_company,crate::api::rectangles
rust_root: rust/
dart_output: lib/src/rust

Additional context I am a bit new to rust, but I have a few projects under my belt. I believe I am following all the documentation but it doesn't seem to work accordingly. I know there may be some things i am missing, but I can't find it anywhere.

welcome[bot] commented 3 hours ago

Hi! Thanks for opening your first issue here! :smile: