Deciding between flutter plugins and flutter modules

163 views
Skip to first unread message

Aman Masipeddi

unread,
Dec 10, 2021, 10:33:12 AM12/10/21
to Flutter Development (flutter-dev)

My team and I are planning to migrate to flutter from native development. We currently have Android and iOS apps and we use local native SDKs for our apps to work. I have to develop a package/SDK which has to be a wrapper around native SDKs so that it can be used in our existing native apps and let us develop our new flutter app with the same package/SDK. I figured out that the plugin works as a wrapper for native SDKs and the flutter module can be used in native apps. IS there any way I can use directly use the plugin in the native apps or import the plugin into a flutter module and then use the module in native apps? Please let me know if anyone has suggestions for this situation or any other work arounds. Thanks in advance.

SUMMARY: I should be able to use that wrapper package in native android and iOS apps as well as the new flutter app.

Ralph Bergmann

unread,
Dec 10, 2021, 1:23:52 PM12/10/21
to Flutter Development (flutter-dev), Aman Masipeddi
I think you have two options

First of all you add the Android native lib to the Android part of the Flutter app and the iOS native lib to the iOS part of the Flutter app. 

1) Use platform channels to call the native lib from the Flutter/Dart code, see https://docs.flutter.dev/development/platform-integration/platform-channels
It’s easiert to implement but you need these platform channels and all the wrapper around. pigeon may help to implement it.

2) Use Flutter::ffi / dart::ffi to call the native lib directly without the platform channels, see https://docs.flutter.dev/development/platform-integration/c-interop
Harder to implement but then you use the native code directly without the async platform channels. But you also needs some wrapper around you native code.

For a biginner I would suggest way #1.
You can do both ways directly in the Flutter app itself or in a Flutter plugin, it’s your choice. 


Ralph

Am 10. Dezember 2021 um 16:33:32, Aman Masipeddi (aman.ma...@gmail.com) schrieb:

My team and I are planning to migrate to flutter from native development. We currently have Android and iOS apps and we use local native SDKs for our apps to work. I have to develop a package/SDK which has to be a wrapper around native SDKs so that it can be used in our existing native apps and let us develop our new flutter app with the same package/SDK. I figured out that the plugin works as a wrapper for native SDKs and the flutter module can be used in native apps. IS there any way I can use directly use the plugin in the native apps or import the plugin into a flutter module and then use the module in native apps? Please let me know if anyone has suggestions for this situation or any other work arounds. Thanks in advance.

SUMMARY: I should be able to use that wrapper package in native android and iOS apps as well as the new flutter app.

--
You received this message because you are subscribed to the Google Groups "Flutter Development (flutter-dev)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to flutter-dev...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/flutter-dev/5d4f9327-586d-485d-b4e9-8345ea8b9c63n%40googlegroups.com.

Aman Masipeddi

unread,
Dec 10, 2021, 3:47:24 PM12/10/21
to Flutter Development (flutter-dev)
Thank you for your reply. If I go with plugins, then can I use that plugin in native apps too?

Ralph Bergmann

unread,
Dec 10, 2021, 4:39:57 PM12/10/21
to Flutter Development (flutter-dev), Aman Masipeddi
Am 10. Dezember 2021 um 21:47:36, Aman Masipeddi (aman.ma...@gmail.com) schrieb:
Thank you for your reply. If I go with plugins, then can I use that plugin in native apps too?


No :-(


But you can create an Android / iOS dependency and use it for Android, iOS, and Flutter.


Use https://jitpack.io/ and https://cocoapods.org/ to create a dependency of your native lib.

Then add these dependencies to your Android, iOS, and Flutter projects.


Ralph


Aman Masipeddi

unread,
Dec 10, 2021, 5:11:46 PM12/10/21
to Flutter Development (flutter-dev)
If I create a dependency, that means anyone can access it right?

Ralph Bergmann

unread,
Dec 11, 2021, 1:13:12 AM12/11/21
to Flutter Development (flutter-dev), Aman Masipeddi

Am 10. Dezember 2021 um 23:11:56, Aman Masipeddi (aman.ma...@gmail.com) schrieb:

If I create a dependency, that means anyone can access it right?


I guess it is possible to create a private repo, but I am not an expert on this topic.
Reply all
Reply to author
Forward
0 new messages