Skip to content

Migrate platform channels to Pigeon 29 - #352

Merged
fotiDim merged 1 commit into
mainfrom
migrate-pigeon-29-asynccallback
Oct 16, 2026
Merged

fotiDim merged 1 commit into
mainfrom
migrate-pigeon-29-asynccallback

Conversation

@fotiDim

@fotiDim fotiDim commented Oct 16, 2026

Copy link
Copy Markdown
Contributor

Alternative to #347: the same Pigeon 29 regeneration, but preserving the existing callback-style native code via @asyncCallback instead of migrating the plugins to native async/suspend.

Approach

Pigeon ≥ 28 changes the generated channel shape by default:

  • @HostApi methods annotated @async → suspend (Kotlin) / async throws (Swift)
  • @FlutterApi methods → async by default

Annotating the async HostApi methods and all FlutterApi methods with @asyncCallback keeps the generated native signatures callback-based, so the hand-written plugins need no changes and no coroutines dependency is required. C++ was already callback-based and is unaffected either way.

Changes

  • pigeon/universal_ble.dart: @async → @asyncCallback (19 HostApi methods) and @asyncCallback added to all 15 FlutterApi methods.
  • Regenerated all five outputs to v29.0.10 (lib/src/universal_ble.g.dart, UniversalBle.g.kt, UniversalBle.g.swift, windows/.../universal_ble.g.{h,cpp}); Dart file formatted.
  • lib/src/universal_ble_pigeon/*.dart: the FlutterApi methods now return Future on the Dart side, so the two callback implementers were made async (bodies stay synchronous).
  • CHANGELOG.md: 3.1.1 note.

No public Dart API change (the callback classes are not re-exported); still 3.1.1.

Differences from #347

  • No native async rewrite: Kotlin stays callback-based (no suspendCancellableCoroutine, no kotlinx-coroutines), Swift stays completion-based (no withCheckedThrowingContinuation, no Task { @MainActor }).
  • Native generated output contains 0 suspend fun and 0 async throws.
  • Windows generated diff is additive only (operator<<, PigeonInternalToString).

Verification

  • flutter analyze — clean
  • flutter test — 285 passed
  • flutter build macos --debug — built
  • flutter build ios --debug --no-codesign — built
  • example/android: ./gradlew :universal_ble:testDebugUnitTest (JDK 21) — BUILD SUCCESSFUL

Notes

  • Windows was not built locally (no Windows toolchain); its generated interface is unchanged and CI covers flutter build windows + ctest.
  • The bulk of the diff is generated code.

Regenerate all Pigeon outputs with 29.0.10 (from 26.3.4). Pigeon >= 28
defaults async methods to native async/suspend; annotate the async HostApi
methods and every FlutterApi method with @asynccallback to keep the existing
callback-based native implementations (Swift completions, Kotlin callbacks)
unchanged and avoid adding a coroutines dependency.

The Dart FlutterApi abstract methods become Future, so the two Dart callback
implementers are updated to async bodies (still effectively synchronous).

Regenerated: lib/src/universal_ble.g.dart, UniversalBle.g.kt,
UniversalBle.g.swift, windows/src/generated/universal_ble.g.{h,cpp}.
@fotiDim fotiDim changed the title Migrate platform channels to Pigeon 29 (asyncCallback alternative to #347) Migrate platform channels to Pigeon 29 Oct 16, 2026
@fotiDim
fotiDim merged commit 6147722 into main Oct 16, 2026
3 checks passed
@fotiDim
fotiDim deleted the migrate-pigeon-29-asynccallback branch October 16, 2026 11:36
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.

2 participants