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 after just clean - just gen #15

Closed jamiepiccolo closed 1 year ago

jamiepiccolo commented 1 year ago

Linux.

Just cloned the repo and executed just clean and then just gen before running flutter run

❯ flutter_rust_bridge_codegen --version
flutter_rust_bridge_codegen 1.47.0
❯ flutter run
Launching lib/main.dart on Linux in debug mode...
info: This is the version for the rustup toolchain manager, not the rustc compiler.
info: The currently active `rustc` version is `rustc 1.65.0-nightly (84f0c3f79 2022-09-03)`
   Compiling autocfg v1.1.0
   Compiling libc v0.2.133
   Compiling anyhow v1.0.65
   Compiling parking_lot_core v0.9.3
   Compiling build-target v0.4.0
   Compiling smallvec v1.9.0
   Compiling scopeguard v1.1.0
   Compiling cfg-if v1.0.0
   Compiling iana-time-zone v0.1.48
   Compiling flutter_rust_bridge_macros v1.47.0
   Compiling bytemuck v1.12.1
   Compiling lazy_static v1.4.0
   Compiling flutter_rust_bridge v1.47.0
   Compiling num-traits v0.2.15
   Compiling num-integer v0.1.45
   Compiling lock_api v0.4.9
   Compiling atomic v0.5.1
   Compiling time v0.1.44
   Compiling num_cpus v1.13.1
   Compiling threadpool v1.8.1
   Compiling parking_lot v0.12.1
   Compiling chrono v0.4.22
   Compiling allo-isolate v0.1.14-beta.2
   Compiling native v0.1.0 (/home/username/Documents/github.com/notagentbilly/frbt-test/native)
    Finished dev [unoptimized + debuginfo] target(s) in 2.68s
ERROR: lib/bridge_generated.dart:37:16: Error: The return type of the method 'NativeImpl.rustReleaseMode' is 'Future<NativeFunction<Int Function(Pointer<Int>)>>', which does not match the return type, 'Future<bool>', of the overridden method, 'Native.rustReleaseMode'.
ERROR:  - 'Future' is from 'dart:async'.
ERROR:  - 'NativeFunction' is from 'dart:ffi'.
ERROR:  - 'Int' is from 'dart:ffi'.
ERROR:  - 'Pointer' is from 'dart:ffi'.
ERROR: Change to a subtype of 'Future<bool>'.
ERROR:   Future<bool> rustReleaseMode({dynamic hint}) =>
ERROR:                ^
ERROR: lib/bridge_definitions.dart:14:16: Context: This is the overridden method ('rustReleaseMode').
ERROR:   Future<bool> rustReleaseMode({dynamic hint});
ERROR:                ^
ERROR: lib/bridge_generated.io.dart:45:9: Error: The parameter 'ptr' of the method 'NativeWire.store_dart_post_cobject' has type 'int', which does not match the corresponding type, 'Pointer<NativeFunction<Bool Function(Int64, Pointer<Void>)>>', in the overridden method, 'FlutterRustBridgeWireBase.store_dart_post_cobject'.
ERROR:  - 'Pointer' is from 'dart:ffi'.
ERROR:  - 'NativeFunction' is from 'dart:ffi'.
ERROR:  - 'Bool' is from 'dart:ffi'.
ERROR:  - 'Int64' is from 'dart:ffi'.
ERROR:  - 'Void' is from 'dart:ffi'.
ERROR: Change to a supertype of 'Pointer<NativeFunction<Bool Function(Int64, Pointer<Void>)>>', or, for a covariant parameter, a subtype.
ERROR:     int ptr,
ERROR:         ^
ERROR: ../../../../.pub-cache/hosted/pub.dartlang.org/flutter_rust_bridge-1.47.0/lib/src/ffi/stub.dart:14:8: Context: This is the overridden method ('store_dart_post_cobject').
ERROR:   void store_dart_post_cobject(DartPostCObject ptr) {}
ERROR:        ^
Building Linux application...                                           
Exception: Build process failed
Desdaemon commented 1 year ago

Related: fzyzcjy/flutter_rust_bridge#108

jamiepiccolo commented 1 year ago

Fixed it by using https://github.com/dart-lang/native/issues/338