Framework
Flutter
Bindings are plain Dart files in your project. They have no registry and do no work at startup, so the AOT compiler removes everything you do not call.
Android (generate flutter)
- Each Java class or interface becomes a Dart extension type over
JObject. Constructors are named by their parameters when overloaded (Intent.new$String$Uri), methods keep the Java name for the primary overload. - Strings:
JStringby default (strict-native), or DartStringwhere lossless (ergonomic-dart). - Java interfaces can be implemented in Dart (
Runnable.implement(...)). Callbacks from any Java thread work; a throwingvoidcallback is reported, not rethrown into Java. - APIs newer than
minApiare guarded and throwNativeApiUnavailableExceptionon older devices before touching JNI. - Java exceptions surface as
NativeJavaExceptionwith class name, message and stack trace. - Kotlin
suspendfunctions in library jars becomeFutures. - Objects hold JNI references: call
release()for deterministic cleanup (otherwise finalizers clean up).
iOS (generate ios)
- Each Objective-C class or protocol becomes a Dart extension type over
ObjCObject; Foundation types already provided bypackage:objective_c(NSString,NSArray, …) are reused. - Selectors map to named parameters:
addItem(item, atIndex: 2). Properties are getters and setters. - Structs such as
CGRectare passed and returned by value.NSError **becomes a thrownNativeObjCError. - Swift-only APIs are reachable through generated
@objcadapters for the Objective-C-representable subset (iOS).
Size
Release APK of the example with one Android API: 14,842,216 bytes, both when bindings were generated for that API only and for the entire SDK (14,842,216 bytes); the app without bindings: 14,426,402 bytes (+415,814 bytes, mostly package:jni's native helper).
Cost per call
Measured on an Android emulator in profile mode: about 1.00 µs per generated JNI call versus about 271 µs for a hand-written MethodChannel round trip. On the iOS simulator (debug mode only): about 34 ns per objc_msgSend getter versus 20.4 µs per MethodChannel round trip. Emulator and simulator figures are not device figures.