Migrating Native Applications to Flutter entrypoint by entrypoint

Organizations with significant investments in native applications will probably migrate flutter feature-by-feature or navigation flow by navigation flow.  They may be able to migrate from the back of the app to the front of the application with all of the Flutter code in a single package or bound to a single every-growing function set. The alternative approach is to migrate targets of opportunity in different locations across the existing application. 

Features-of-opportunity migration means that we will probably end up with a set of unrelated features that will get invoked at different points in the existing native application.  We organize those work streams or flows into their own package.  Each of those packages is essentially its own mini Flutter program with its own main() program. 

Android and iOS native applications can import a single Flutter module that should contain all the Flutter functionality. We need to include all various Flutter functions in that single module. 

Our business-related packages are bundled into a single module that is built as an Android or iOS library.  That module defines the various main() or package entry points by defining functions that are annotated with @pragma('vm:entry-point').  Developers add new annotated entrypoints for every business flow that is migrated to Flutter, each in their own package. 

The shared module is pulled into the native application as a library. @pragma() annotated functions are visible to native code in both iOS and Android. The mobile native applications can launch individual Flutter packages by calling the annotated entrypoints by name. 



Code examples are not yet included and will be added at some future date.


This is a canonical sample directory structure that supports the diagram above. Int includes two shared packages developed by the team that are used in the flow packages package_1 and package_2.  There is also a single common_module that is built into iOS and Android libraries.  The common module directly includes package_1 and package_2 and indirectly includes internal_package_1 and internal_package.





This sample structure also includes standalone iOS and Android test jigs that let us run package_1 and package_2 without having to integrate into the existing/overarching mobile applications for every change.  It isn't required but can simplify demonstrations even though it comes with some setup and initialization complications due to the fact it may need to simulate some services of the existing main production applications.

  • commmon_module: The .android/ and .ios/ directories exist when creating modules rather than applications. They are ephemeral and not managed under version control.
  • test_jig: The test_jig projects are standalone programs that developers might use for testing and demonstrations of those business flows in the mobile emulators, simulators and local web browsers. The android/, ios/, and web/ projects are stub launchers for stand alone applications and are managed under version control.

Android and iOS Navigation  

The discussion above does include the actual code required to call an entrypoint. You can search the internet for that code.  

The discussion above does not include Android or iOS specific navigation.  That may be covered in a future blog article.

Revision History

Created 2024 05


Popular posts from this blog

Understanding your WSL2 RAM and swap - Changing the default 50%-25%

Installing the RNDIS driver on Windows 11 to use USB Raspberry Pi as network attached

DNS for Azure Point to Site (P2S) VPN - getting the internal IPs