Using dart pigeon in a federated model - dart

I"m looking at converting a dart package (https://pub.dev/packages/sounds) to a federated model using pigeon.
The documentation around combing these two pieces is a little sparse.
Looking at the video_player sample (https://github.com/flutter/plugins/tree/master/packages/video_player/video_player_platform_interface) seems to suggest a federated model as the web platform is separate.
However both the android and ios packages are part of the main package.
Is this just an historical artefact or do the ios and android packages still need to be part of the main plugin?
If they can be separated out what is the correct package(s) structure?
Are then any open source plugins that use pigeon in a fully federated model that could be used as samples?

Having the iOS and Android projects inside of the main package is the standard as of now. I looks like there's discussion around generating federated plugins when running flutter create.
There is an article on the url_launcher federated plugin model refactor which is helpful for figuring out the FS structure:
https://medium.com/flutter/how-to-write-a-flutter-web-plugin-part-2-afdddb69ece6
https://github.com/flutter/plugins/tree/master/packages/url_launcher
As far as Pigeon is concerned, because Pigeon is in pre-release and the federated plugin design is fairly new, I doubt there are any fully federated open source packages using Pigeon. However it seems like your message spec would be owned by the my_plugin_platform_interface package and the generated code would be copied over to your platform specific package e.g. my_plugin_ios, my_plugin_android, my_plugin_macos, etc.
Hope that's of some use.

Why is video_player's android and iOS code not federated?
Is this just an historical artefact or do the ios and android packages still need to be part of the main plugin?
It appears to either be:
a convenience: flutter create will create a package easily with android/ios boilerplate
historical artefact: They might have created the package before federated plugins were released. (This is why people have requested the flutter create plugin template to generated a federated plugin automatically).
Correct package structure
If they can be separated out what is the correct package(s) structure?
They can be separated out.
For pigeon specifically, you can put the Dart generated code (from Pigeon) in your Platform specific interface, and your Native platform generated code (from Pigeon) in your platform specific package.
In your platform specific package, you should declare it to be a federated plugin (see docs and url_launcher), where url_launcher is the app facing package in that example:
flutter:
plugin:
implements: url_launcher
platforms:
macos:
pluginClass: UrlLauncherPlugin
fileName: url_launcher_macos.dart
Example package
If you take a look at url_launcher, all platforms have federated plugin packages.
Why federate
The advantage of creating a separate platform specific package is that a user can override the default implementation. For video_player, a user cannot override Android or iOS implementation because it is in the app-facing package.
More reading
After writing the above, I found this GitHub issue which goes over a lot of our concerns: https://github.com/woodemi/quick_flutter.brick/issues/22

Related

Firebase-Unity Project: Exporting for iOS on Windows 10. Workaround?

Recently added Firebase Storage and Authentication to my Unity project. I work on Windows, have a single Unity Pro License, and want to export my App for iOS, as I have done many times before in this dev process.
However, since the addition of Firebase, I'm told I apparently can't export my Firebase-Enabled Unity project for iOS without swapping Unity to an OSX device (which I don't have in comparable quality).
I've noticed a singular thread here where a supposed workaround was discussed, but can't seem to pull it off myself:
"The plugin that comes with firebase depends on cocoapods to handle
transient dependencies. If you look at the Assets ->
PlayServicesResolver -> IOSResolver -> Settings
You can configure it to generate the podfile but not do the remaining
steps." - from user johnb003, March 18th 2017.
Can't seem to find the configuration settings described here. Scoured the forums/communities for solutions, but no results elsewhere.
So, that said, any other Firebase user have a workaround for this issue? I adore the collective Google has put together with their product, but I can't really afford to invest in another Unity Pro License just for the sake of working off of my sub-standard Macbook. Thoughts?
Looks like there's a Google Github project, Unity JAR resolver, describing how the Unity Play Services Resolver works for each target platform.
The documentation is pretty extensive, and solutions are use-case specific, so I can't give you much help on specific podfile settings, but hopefully you can sift through it yourself.

Can we have an app share server(API) and client code (iOS/Android/Web) using Flutter/Dart?

Since Flutter already has taken a shared library approach for Android and iOS apps; is it possible to extend this idea to add server (API) code using Dart and web content using Angular-Dart? I can see examples of server and client code being shared, and can see Android and iOS code being shared (Flutter) - are there any examples where business logic is shared between iOS, Android, web and API code? Something similar to kotlin-multiplatform?
Just move your code in another Dart package that
does not depend (directly or transitive) on
dart:ui (Flutter)
dart:html or Angular (browser)
dart:io (server or console)
Everything that needs a dependency to one of these needs to be abstracted and then injected (passed as argument) when you use the platform-independent code on a specific platform.
You actually can share code between server and Flutter that depends on dart:io but such a dependency would prevent code being used in the browser.
See also
https://www.youtube.com/watch?v=PLHln7wHgPE
In a project I'm working on I have built_value model classes and built_redux (actions, reducers, state) in the shared package and use it in Flutter and Angular.
The main pain point was Firebase where the whole Firebase API needed to be abstracted because Angular and Flutter use different Firebase packages.
It wasn't too difficult, but cumbersome.
There are attempts to create a package that provide such an abstraction out of the box, but I don't know about the progress.

What is the difference between a unity plugin and a dll file?

i am new to Unity and i am try to understand plugins. I have got the difference between a managed plugin and a native plugin, but what is not very clear to me is:
what is the difference between a plugin and a dll? what should i expect to find in an sdk to make it usable in my unity project?
Thanks a lot
To expand on #Everts comment instead of just copying it into an answer, I'll go a little into details here
What is a plugin?
It's a somewhat vague word for a third-party library that is somehow integrated with the rest of your game. It means that it neither is officialy supported by Unity, nor is it a part of your core code. It can be "plugged" in or out without altering its internals, so it must provide some kind of API that can be used by the game code.
For example, you'll find many plugins that handle external services like ads, notifications, analytics etc. You'll also find a couple of developer-tools that can also be called plugins, like tile-based map editors and such.
Plugins come in many forms - DLL files are one example but some plugins actually provide full source code for easier use. And of course, other plugins will provide native code for different platforms, like Objective-C for iOS or .jars for Android.
So to answer your first question:
DLL is simply a pre-compiled source file that can be a part of a plugin
A plugin is a whole library that can consist of multiple files with different formats (.cs, .dll, .jar, .m etc)
What do you need to use an sdk?
First of all - documentation. Like I said before, and like you noticed yourself, not all plugins give you access to the source code. And unfortunately, not many sdks have extensive and developer-friendly documentations so it can be a tough task to actually understand how to use a given sdk.
Secondly - the code. Many sdks give you some kind of "drag & drop" library, a single folder with all the neccessary files inside that you simply add to your Unity projects. I've also seen sdks that use Unity packages that you have to import via Assets > Import Package > Custom Package.
Once you have the code and documentation it's time to integrate it with your game. I strongly recommend using an abstract lyer in your game as, in my experience, you often have to change sdks for various reasons and you don't want to rewrite your game logic every time. So I suggest encapsulating sdk-related code in a single class so that you have to change only one class in your code when switching from, say, one ad provider to another (and keep the old class in case you need to switch back).
So you basically need three things:
Documentation (either a readme file or an online documentation)
The code (precompiled or source)
A versatile integration

Where I can find in Dart SDK an implemention of the UnmodifiableSetView?

Where I can find in Dart SDK an implemention of the UnmodifiableSetView?
In C# language exists System.Collections.Immutable.ImmutableHashSet<T>.
In Java language exists Collections.unmodifiableSet().
But I cannot find anything similar in Dart SDK.
Where I can find it in Dart SDK?
P.S.
I use Dart language not for compiling it to the Javascript language.
I use it (as is) for the computations and I need UnmodifiableSetView but I connot find it in Dart SDK.
There is an UnmodifiableSetView in package:collection.
This is an official implementation of an unmodifiable view of a Set created by the Dart team.
There is no similar class in the platform libraries. Unlike Java and C#, the Dart platform libraries are limited in size, and functionality that can just as easily be implemented in a separate library are made available as packages instead.
It's always a question about the trade-off between convenience (making everything immediately available) and size/discoverability (don't overwhelm the user).
If you are looking for functionality in, say, dart:collection, and doesn't find it, then the package:collection package is a good second location to look. Not all dart:-libraries have corresponding packages, but some do.

AndroidAnnotations minimum API supported

I would like to know the minimum Android API level AndroidAnnoatations supports ? I could not find any info on their website .
regards,
Felix T
I think there is NO specific minimum Android API Level that AndroidAnnotations can work with.
Since it's a compilation tool, I mean it's related with the Java files and it's related not with Android API.
If you build an Android project with AndroidAnnotations, then some intermediate java files will be generated, which will be the final java file for Java compiler, and that's all. It's just used for convinience of your development. The generated apk file will not have information about AndroidAnnotations - it's something like a conversion tool (shorter exprssion to long complicated expression, which is not visible to you).
I think that you can use AndroidAnnotation from Android API Level 1.
Maybe some of the annotations cannot be used in Android API 1 project, but even if such case happens, just removing only that specific annotation in your .java file will make it work.

Resources