website/docs/guides/miscellaneous/upgrade/v2.md
This guide shows how to upgrade a project using flutter_rust_bridge V1 to V2.
:::info This is just one approach, see below for more approaches. :::
flutter_rust_bridge_codegen integrate.api.rs) to rust/src/api/simple.rs. (You can also split into multiple files,
e.g. apple.rs, orange.rs, etc.)flutter_rust_bridge_codegen generate --watch.Surely, there are alternative approaches. For example, if you want to keep the compilation and integration between Rust and Dart, or like to use command line arguments, just find the corresponding counterparts in V2 and rename things.
</details>SyncReturn type becomes annotation: Change fn f() -> SyncReturn<T> {} to #[frb(sync)] fn f() -> T {}api.functionName() -> functionName()DartAbi -> DartDynamic (simple name alias)ZeroCopyBuffer<T> -> T (just remove the wrapper, it is automatically zero-copy by default)RustLib.init() when starting app.flutter_rust_bridge_codegen -> flutter_rust_bridge_codegen generateflutter_rust_bridge_serve -> flutter_rust_bridge_codegen build-web + standard flutter run (or run in IDE)DartSafe -> simply remove itflutter_rust_bridge::RustOpaque -> crate::frb_generated::RustOpaque (simply moved)flutter_rust_bridge::StreamSink -> crate::frb_generated::StreamSink (simply moved)StreamSink.close -> simply remove it (it is auto closed when the object is dropped)Some flags are removed, when, for example, they exist mainly for compatibility of later V1 with earlier V1 versions. If you find the removed flag important for your scenario, feel free to create an issue.
</details>:::info Here are some concrete possibilities, which may or may not be your own case. This serves to check whether there are missing cleanup steps. :::
Podfile (if using method 2).build.gradle file.android/app/src/main/jniLibs/ folder, if this is where the old binaries are stored.bridge_generated:
ios/Runner/bridge_generated.h file#import "bridge_generated.h" in ios/Runner/Runner-Bridging-Header.hbridge_generated.h from the "Copy Bundle Resources" build phaseios/Runner/libmyapp.a and remove it from the "Link Binary With Libraries" build phase.print("dummy_value=\(dummy_method_to_enforce_bundling())"); line in ios/Runner/AppDelegate.swift if
you had that workaround.