-
-
Notifications
You must be signed in to change notification settings - Fork 246
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Use jnigen
and ffigen
to call Java/Kotlin/Swift/ObjC natively without the MethodChannels
#1444
Comments
For web you don't need any method channels or similar since Dart has JS interopt built-in: https://dart.dev/web/js-interop |
|
ffigen for Swift was introduced in Dart 2.18 which shipped with Flutter 3.3, see https://medium.com/flutter/announcing-flutter-3-3-at-flutter-vikings-6f213e068793 Then there's dart:ffi (which is part of the Dart SDK), and package:ffi (distributed via pub). ffigen makes use of a specific version of package:ffi. ffigen is also the tool where most of the Swift binding magic and its improvments happens. In addition to that, Swift ffi is considered experimental, however cupertino_http (a package using those Swfit/objc bindings) is considered stable. |
Looking at the wording in the Dart 2.18 announcement, it looks like it's just a documentation issue (and the availability of a generator), not that it didn't work with an older version of the SDK. The changelog for 2.18 doesn't mention anything (or I'm blind) so that would indicate my assumption may be true. (FYI, I am pretty familiar with FFI: https://github.com/objectbox/objectbox-dart/graphs/contributors - the whole thing is based on a C(++) library) |
@vaind I read somewhere about min Dart 3 but I don't recall where exactly, it could be a docs issue so go ahead and try it out. |
I've evaluated this (in the experiment PR #1622) so let me summarize the findings.
Risks
Next steps
Notes on code generation updatesSince this involves code generation, updating the SDK would have an additional step (this should be part of upgrade script that's triggered by the updater, e.g. |
I'm currently looking into replay integration for Android and while it's not a hard requirement, it would greatly simplify things FYI @buenaflor @denrase |
After working with (and around) jni/jnigen in the replay support PR #2011, I don't feel it's feasible to update to it at the moment. The issue is that we need (for native callbacks) at least jni/jnigen package at v0.6.0, which in turn depends on Dart SDK v3.1.0 (Flutter 3.13). We currently keep compatibility of sentry_flutteer with a much older version (Dart SDK 2.17, i.e. Flutter 3.0) so not sure it's worth bumping without further consideration of the benefits we get. Blocked by Dart SDK 3.3 |
We may need to check proguard support, see dart-lang/native#1626 and flutter/flutter#136909 |
Description
https://dart.dev/guides/libraries/java-interop and https://dart.dev/guides/libraries/objective-c-interop
Depends on Dart 3, still experimental.
Can probably use
gen
packages (ffigen) for Linux, Windows, etc.Need to figure out how to call Web without
MethodChannels
The text was updated successfully, but these errors were encountered: