Target Flutter?

Is there some way I can target Flutter?

Leo,

I have not looked at Flutter yet, but was planning to do so at some time in the near future. Being cross-platform, I’m not sure what their API entry points looks like, but if they provide an Objective-C (or C) .framework or static library for iOS/macOS, you should be able to import that, similarly, if they provide a .jar or a Grade package for Android, you should be able to just use that directly.

What platform(s) are you looking at?

I am looking to use iOS and Android with Flutter.

I can’t see any official docs on how to use jar and static libs.

Here is an android example: android - How to access the Java classes and methods of a local .jar file from kotlin code in flutter - Stack Overflow
And here is an iOS example: Importing a static library (Rust .a) to Flutter project in iOS - Stack Overflow

Many especially jar questions are unresolved on SO

I am also unsure wether you can add them directly - to either a flutter project or to flutter package.

Many mentions platform channel. But that would mean you would have to call the jar in case of android from java/kotlin, and hen send the result back to dart. Which I think is a bit complicated and I am unsure wether maintaining types is needed manually in some way.

If Flutter has a .jar or .aar, you can just add a reference to it to your project.

For iOS, if there’s a .h/.a combo, or framework, you can use the Import Project feature (see link in previous reply) top import those into a .fx file you can reference in your project.

We are talking past each other. I am looking for the opposite - to create jar/static library in elements - then using it in flutter.
As I understand this should be possible when it comes to .net, java?

Ah. sure. Just create a new “Java|Class Library” and/or “Cocoa|Static Library (iOS)” project, and you should be good to go, then!?

As far I can tell there so no binary library format in dart. So yes it seems to be the only way.
Also, as I said previously it’s not seem to be very well documented how to use the binaries - but it’s more of a dart and flutter question

1 Like

I read about flutter ffi. This means there can be a single C implementation that both the Android and iOS Flutter project uses - instead of having separated jar and static library implementations as in the approach we talked about.

Is possible to compile into C with Elements, in a format that Flutter ffi can use?

Define “compile into C”? Elements can generate C-compatible .h files along with your Island binaries.

When working in Haxe I needed to manually compile (static library) for different architectures. I am not that familiar with C. Would Island binaries work on (Flutter) iOS and Android? I don’t think so.
Maybe using jar and static library is the best way

I don’t see why they wouldn’t.

Ok, I will probably try it!

1 Like

Here is a thread which contains all arch setup needed in Haxe for Apple Watch: Missing hxcpp.h in cpp compilation - #18 by haxiomic - haxe-cpp - Haxe Community

(Haxe → C in Xcode)

That’s why I am assuming there will be problem having desktop static library used in iOS for instance…