'is it possible to embed an ionic application within a flutter application?

To be more precise, I already have a huge app writen in Ionic and now we're considering to migrate it to flutter, but we can't rewrite it from scratch, both ionic and flutter should coexist.

So my question is: can I have a flutter app as a "host" and import / run the ionic app inside it? Something like a micro frontend.

Until now I was able to build the target ionic app and import it on the flutter app, under android folder, but it does not feels like a productive way to approach the problem.

I also googled a little bit about this integration, but did not find anything that solves this problem.

I appreciate any help on this topic.



Solution 1:[1]

Yes, it is possible, but very cumbersome.

I did it for a project and embedded 3 ionic apps inside flutter.

I'll not list every problem that i faced but just go through some points to give you an idea.

  • You will need to take care of some cordova plugins that use native code, for Android copy and paste some folders like CordovaLib,cordova and use it as a library. For iOS you must add the plugin files like *.h to the compiles list inside Xcode and create an Pod to get the cordova resources (that's the way i did)

  • To "launch" the app for android you need to start the cordova activity and for iOS you need to play with UINavigationController and FlutterViewController, and of course create a method channel to be possible to call it from Flutter.

  • For multiple apps, you have to mess inside de cordova code to get the app from the right www folder and be sure to equalize every plugin version between apps.

  • Some packages from flutter may clash with ionic/cordova libs

  • Every change you do to your ionic application it must be tested outside flutter and within it to see if there's any mismatch behavior that you didn't expect, specially when adding new plugins.

  • Maybe some permission issues will arrive between applications like camera or localization.

I know thats not the answer, but when searching on how to do it, i stumbled upon this question a few months ago and it still without any answer on this problem.

But my final take is that the effort of joining together all pieces using multiple languages and frameworks together with the job of maintaining this spaghetti behemoth is not worth it and you'll save yourself of a tremendous headache.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Rodrigo M.