Desdaemon / flutter_rust_bridge_template

Template for Flutter + Rust integration with flutter_rust_bridge.
https://desdaemon.github.io/flutter_rust_bridge_template/
Apache License 2.0
120 stars 63 forks source link

Build fails: IntoIntoDart<_> is not implemented #51

Closed TheSunCat closed 1 year ago

TheSunCat commented 1 year ago

Hi! I'm looking to use this template to develop an app, and tried just running it after cloning (made sure I have what's listed in the README installed). I ran flutter run and see the following error:

   Compiling native v0.1.0 (/home/apm/Documents/flutter_rust_bridge_template/native)
error[E0277]: the trait bound `api::Platform: IntoIntoDart<_>` is not satisfied
  --> src/bridge_generated.rs:25:33
   |
25 |     FLUTTER_RUST_BRIDGE_HANDLER.wrap(
   |                                 ^^^^ the trait `IntoIntoDart<_>` is not implemented for `api::Platform`
   |
   = help: the following other types implement trait `IntoIntoDart<D>`:
             <() as IntoIntoDart<()>>
             <(A, B) as IntoIntoDart<(AD, BD)>>
             <(A, B, C) as IntoIntoDart<(AD, BD, CD)>>
             <(A, B, C, D) as IntoIntoDart<(AD, BD, CD, DD)>>
             <(A, B, C, D, E) as IntoIntoDart<(AD, BD, CD, DD, ED)>>
             <Box<T> as IntoIntoDart<T>>
             <DartCObject as IntoIntoDart<DartCObject>>
             <DartOpaque as IntoIntoDart<DartOpaque>>
           and 22 others
note: required by a bound in `wrap`
  --> /home/apm/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flutter_rust_bridge-1.80.1/src/handler.rs:51:18
   |
47 |     fn wrap<PrepareFn, TaskFn, TaskRet, D>(&self, wrap_info: WrapInfo, prepare: PrepareFn)
   |        ---- required by a bound in this associated function
...
51 |         TaskRet: IntoIntoDart<D>,
   |                  ^^^^^^^^^^^^^^^ required by this bound in `Handler::wrap`

For more information about this error, try `rustc --explain E0277`.
error: could not compile `native` (lib) due to previous error
[2023-08-02T20:51:41Z INFO  cargo_ndk::cli] If the build failed due to a missing target, you can run this command:
[2023-08-02T20:51:41Z INFO  cargo_ndk::cli] 
[2023-08-02T20:51:41Z INFO  cargo_ndk::cli]     rustup target install armv7-linux-androideabi

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:cargoBuildDebug'.
> Process 'command 'cargo'' finished with non-zero exit value 101

Just to make sure, I ran the command suggested by cargo_ndk:

[apm@apg ~/Documents/flutter_rust_bridge_template]$ rustup target install armv7-linux-androideabi
info: component 'rust-std' for target 'armv7-linux-androideabi' is up to date
Desdaemon commented 1 year ago

flutter_rust_bridge recently released a new version (v1.79) that requires rerunning the codegen. You can work around this with just gen, and I will try to update the template later this week as well.