Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flutter #7

Open
lattice0 opened this issue Jul 3, 2021 · 3 comments
Open

Flutter #7

lattice0 opened this issue Jul 3, 2021 · 3 comments

Comments

@lattice0
Copy link

lattice0 commented Jul 3, 2021

I've been designing a Rust library for usage with Flutter. I see that you're doing Kotlin/Java <-> Rust here, but you mention Flutter.

Is there a plan to make a template for Flutter? Because there are 2 methods to consider: FFI vs Plugin call. Since plugin calls are very slow, FFI should be prefered, but what to do when Rust needs JNI objects? You can't pass them through Flutter's FFI

@ivnsch
Copy link
Owner

ivnsch commented Sep 24, 2021

There are other repos with Flutter templates (which you probably have found by now). I don't see a need to make another one.

Just to clarify, why would Rust need JNI objects when using (C based) FFI? As far I understand, with Flutter you use C FFI for everything, so you don't have to touch JNI at all.

Sorry for the late reply, for some reason I was not subscribed to all the notifications and didn't see this.

@lattice0
Copy link
Author

There are other repos with Flutter templates (which you probably have found by now). I don't see a need to make another one.

Just to clarify, why would Rust need JNI objects when using (C based) FFI? As far I understand, with Flutter you use C FFI for everything, so you don't have to touch JNI at all.

Sorry for the late reply, for some reason I was not subscribed to all the notifications and didn't see this.

Sometimes you need to call C code through plugin calls through JNI. For example, getting a C pointer to an opengl renderer so I can pass to the Rust library via FFI

@ivnsch
Copy link
Owner

ivnsch commented Sep 28, 2021

I'd solve this kind of situation at library level, i.e. the native (Android in this case) library used in the plugin would have a dedicated Rust binary with the JNI bindings. It would be invisible at plugin/Flutter level.

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

No branches or pull requests

2 participants