Skip to content

SDK: add Flutter/Dart bindings via flutter_rust_bridge#162

Open
saltyskip wants to merge 9 commits into
mainfrom
feat/flutter-dart-sdk
Open

SDK: add Flutter/Dart bindings via flutter_rust_bridge#162
saltyskip wants to merge 9 commits into
mainfrom
feat/flutter-dart-sdk

Conversation

@saltyskip
Copy link
Copy Markdown
Owner

Summary

  • Adds client/mobile/flutter_ffi/ — new Rust crate annotated for flutter_rust_bridge v2. Write Rust once; CI generates Swift + Kotlin + Dart.
  • Adds client/mobile/flutter_dart_wrappers/ — committed hand-written Dart wrapper + Flutter plugin boilerplate (analogous to android-wrappers/). Exposes RiftSdk.create(publishableKey: ...) with SharedPrefsRiftStorage as the default storage backend.
  • Adds client/mobile/build_flutter.sh — runs flutter_rust_bridge_codegen generate, builds iOS XCFramework + Android .so, assembles dist/flutter/ as a distributable plugin tarball.
  • Updates mobile-sdk-ci.yml — adds flutter-dart-gen job that verifies Dart binding generation on every PR.
  • Updates mobile-sdk-release.yml — adds build-flutter job; ships rift-flutter-sdk-{tag}.tar.gz in the GitHub release alongside the existing iOS and Android artifacts.

Storage: Dart layer owns persistence (no UniFFI foreign trait). create() takes pre-loaded RiftState; state-mutating methods return a new snapshot. SharedPrefsRiftStorage handles it transparently by default.

Test plan

  • CI flutter-dart-gen job passes (Dart bindings generate cleanly)
  • build-flutter release job produces flutter-sdk.tar.gz artifact
  • Download artifact, add as path dep in a Flutter app, flutter pub get resolves
  • RiftSdk.create(publishableKey: 'pk_live_...') initializes without error on device

🤖 Generated with Claude Code

Adds a new `flutter_ffi` Rust crate that exposes the same API surface as
the existing UniFFI SDK but annotated for flutter_rust_bridge v2. CI
generates Dart bindings with `flutter_rust_bridge_codegen`, builds native
iOS XCFramework + Android .so files, and ships a self-contained
`rift-flutter-sdk-{tag}.tar.gz` release artifact alongside the existing
iOS and Android tarballs.

Storage is owned by the Dart layer (no foreign trait needed): `RiftSdk.create()`
accepts pre-loaded state; methods that mutate state return a `RiftState`
snapshot for Dart to persist. The `SharedPrefsRiftStorage` default
implementation handles this transparently out of the box.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented May 25, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
rift Ready Ready Preview, Comment May 25, 2026 9:09pm

Request Review

flutter_rust_bridge_codegen v2.12 dropped file-glob rust_input in favor
of Rust module paths. Move the API to src/api.rs and use
--rust-input crate::api --rust-root flutter_ffi/ everywhere.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
frb v2 detects the Dart package by walking up from dart-output to find
pubspec.yaml. Generating into dist/ (no pubspec.yaml) fails. Fix: use
--dart-root flutter_dart_wrappers/ so frb finds the pubspec, and drop
--c-output / --no-web which aren't guaranteed flags in v2.12.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
frb resolves --dart-output relative to cwd (not --dart-root), then walks
up from that path looking for pubspec.yaml. Using "lib/src/rust/..." resolves
inside client/mobile/ with no pubspec there. Using the full path
flutter_dart_wrappers/lib/src/rust/frb_generated.dart lets frb find
flutter_dart_wrappers/pubspec.yaml correctly.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
flutter_rust_bridge_codegen v2 requires Dart/Flutter to be available to
generate Dart bindings (it runs dart analysis internally). Add
subosito/flutter-action@v2 to both the CI gen job and the release build-flutter job.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
flutter_rust_bridge_codegen v2 requires freezed (Dart codegen backend),
freezed_annotation, build_runner, and flutter_rust_bridge as dependencies
before it will generate bindings.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
frb v2 treats --dart-output as a directory name, not a file path — it was
creating frb_generated.dart/ as a directory. Removing the flag lets frb
place files in its expected default location inside the dart-root.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
frb v2 treats --dart-output as a directory: it places frb_generated.dart
inside it. Passing the full file path (ending in .dart) caused frb to
create a directory named frb_generated.dart. Use the parent dir instead.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
macOS ships bash 3.2 which doesn't support associative arrays (declare -A,
a bash 4+ feature). The build_flutter.sh xcodebuild runner is macOS-15 so
this was the crash on line 65. Replace with a plain case statement.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant