ivnsch / rust_android_ios

Android / iOS app with shared Rust logic

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Flutter

lattice0 opened this issue · comments

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

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.

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

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.