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

Higher-level Plugin api akin to flutter-rs #16

Closed
maxjoehnk opened this issue Jun 13, 2021 · 4 comments · Fixed by #17
Closed

Higher-level Plugin api akin to flutter-rs #16

maxjoehnk opened this issue Jun 13, 2021 · 4 comments · Fixed by #17
Labels
enhancement New feature or request

Comments

@maxjoehnk
Copy link

I'm working on an application written in rust with flutter as the UI and was using flutter-rs until now.
I've implemented some custom channels and flutter-rs has a nice abstraction for flutter plugins as well as the different channel types.

Do you have any intentions to implement something similar?

@knopp
Copy link
Contributor

knopp commented Jun 13, 2021

Have you taken look at the examples? There are rust channel handlers registered with message manager.

https://github.com/nativeshell/examples/blob/main/src/platform_channels.rs
https://github.com/nativeshell/examples/blob/main/src/file_open_dialog.rs

If you want to you can even package your handler as a crate, all you'd need as an entry point is for your plugin to register with message manager.

@maxjoehnk
Copy link
Author

Yeah I've seen the examples. But if you compare the api to the flutter-rs api it's way more cumbersome to work with.
In flutter-rs all you need to do is implement the trait MethodCallHandler and then you can register it with the engine.
There is also a Plugin trait which allows registration of channels to the engine.

For reference here you can find the usage of the Plugin trait and here you can see how the usage of the MethodCallHandler trait looks like.

@knopp
Copy link
Contributor

knopp commented Jun 13, 2021

I see. Would something like this work?

https://gist.github.com/knopp/139f7b2b02ce4f59e2649bc1560276c3

The Plugin struct is fairly easy to implement on top of existing machinery, but I don't mind including it if it makes things more convenient.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants