当先锋百科网

首页 1 2 3 4 5 6 7

【报错】

Launching lib/main.dart on Linux in debug mode...
Finished dev [unoptimized + debuginfo] target(s) in 0.04s
ERROR: lib/bridge_generated.dart:837:9: Error: The parameter 'ptr' of the method 'FlutterRustBridgeExampleWire.store_dart_post_cobject' has type 'int', which does not match the corresponding type, 'Pointer<NativeFunction<Bool Function(Int64, Pointer)>>', 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)>>', or, for a covariant parameter, a subtype.
ERROR: int ptr,
ERROR: ^
ERROR: ../../frb_dart/lib/src/basic.dart:153:8: Context: This is the overridden method ('store_dart_post_cobject').
ERROR: void store_dart_post_cobject(
ERROR: ^
Building Linux application...
Exception: Build process failed

【解决方案】

$ export REPO_DIR=$PWD
$ cd /

$ flutter_rust_bridge_codegen \
    --rust-input $REPO_DIR/rust/src/api.rs \
    --dart-output $REPO_DIR/lib/bridge_generated.dart \
    --c-output $REPO_DIR/ios/Classes/bridge_generated.h
[2021-10-22T14:39:33Z INFO  flutter_rust_bridge_codegen] Picked config: Opts { rust_input_path: "/home/consulting/Documents/native_add/rust/src/api.rs", dart_output_path: "/home/consulting/Documents/native_add/lib/bridge_generated.dart", c_output_path: "/home/consulting/Documents/native_add/ios/Classes/bridge_generated.h", rust_crate_dir: "/home/consulting/Documents/native_add/rust", rust_output_path: "/home/consulting/Documents/native_add/rust/src/bridge_generated.rs", class_name: "NativeAdd", dart_format_line_length: 80, skip_add_mod_to_lib: false }
[2021-10-22T14:39:33Z INFO  flutter_rust_bridge_codegen] Phase: Parse source code to AST
[2021-10-22T14:39:33Z INFO  flutter_rust_bridge_codegen] Phase: Parse AST to IR
[2021-10-22T14:39:33Z INFO  flutter_rust_bridge_codegen] Phase: Transform IR
[2021-10-22T14:39:33Z INFO  flutter_rust_bridge_codegen] Phase: Generate Rust code
[2021-10-22T14:39:33Z INFO  flutter_rust_bridge_codegen] Phase: Generate Dart code
[2021-10-22T14:39:33Z INFO  flutter_rust_bridge_codegen] Phase: Other things
[2021-10-22T14:39:34Z INFO  flutter_rust_bridge_codegen] Success! Now go and use it :)

$ cd $REPO_DIR