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.
Video
Code
Directory
- 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 not include Android or iOS specific navigation. That may be covered in a future blog article.
Comments
Post a Comment