NewsCrawler.org

Flutter Native Interop Is Stable, and Platform Channel Is Being Retired

The article reports that Flutter Native Interop became stable after the release of Flutter 3.50, and the author expects Platform Channel[1] to be retired in about two more versions. The Objective-C bindings from FFIgen and the Java and Kotlin bindings from JNIgen are now stable, so Dart can call native APIs directly through FFI[2] or JNI[3]. Pigeon[4] lets developers define a cross-platform API once in Dart and generates the Dart and Swift or Kotlin interfaces. Existing Pigeon definitions still work, but the calls no longer have to go through MethodChannel message passing.

The same Pigeon definition can generate two backends: Android, iOS and macOS use FFI or JNI, while Windows and Linux keep Platform Channel. The author notes that FFIgen does not parse arbitrary Swift APIs, so Swift code must first expose an Objective-C compatible entry point.

The new mode allows synchronous calls, and the Host API of Pigeon Native Interop can be called directly from a background Isolate without a RootIsolateToken. However, calls run on the thread that makes them, so @TaskQueue is not supported in this mode, a slow synchronous JNI call on the main Dart Isolate may still freeze frames, and native code that touches Android Activity or iOS UIKit must switch back to the platform main thread itself.

Read the original juejin.cn

Discussion

Most reactions are a simple like. One commenter argues that accessing phone features on iOS and Android is still more convenient through Platform Channel.

Sources

  • CNJuejin ZH

    Flutter Native Interop 稳定了,Platform Channel 要退场了

    7 likes865 views4 comments2 saves

Published: First seen: Читать по-русски

Open as a page