<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Muhammad Rizky on Medium]]></title>
        <description><![CDATA[Stories by Muhammad Rizky on Medium]]></description>
        <link>https://medium.com/@muhammadrisky1401?source=rss-8cd4c1cce7e9------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*ukUsfiWTrFju5z_p</url>
            <title>Stories by Muhammad Rizky on Medium</title>
            <link>https://medium.com/@muhammadrisky1401?source=rss-8cd4c1cce7e9------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 05:32:30 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@muhammadrisky1401/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Flutter get_it: One Container Per Feature, Not One Global Locator]]></title>
            <link>https://levelup.gitconnected.com/flutter-get-it-one-container-per-feature-not-one-global-locator-885b68d786d2?source=rss-8cd4c1cce7e9------2</link>
            <guid isPermaLink="false">https://medium.com/p/885b68d786d2</guid>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[software-architecture]]></category>
            <category><![CDATA[clean-architecture]]></category>
            <category><![CDATA[dependency-injection]]></category>
            <dc:creator><![CDATA[Muhammad Rizky]]></dc:creator>
            <pubDate>Wed, 23 Sep 2026 14:40:17 GMT</pubDate>
            <atom:updated>2026-09-23T14:40:17.481Z</atom:updated>
            <content:encoded><![CDATA[<h4>A feature container that starts completely empty — blind to every dependency the app already registered — sounds like extra work for no reason. It is what makes “delete this feature” a statement you can actually check.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aff4fPob4uzndZH_uZ-O1g.jpeg" /></figure><p>Most Flutter apps that use a service locator use exactly one of them. GetIt.instance is a singleton; the docs show it as a singleton, and every tutorial registers everything into it during main(). Anything in the app can then ask for anything.</p><p>That works until the app is big enough that “anything can ask for anything” stops being a convenience and becomes the reason nothing can be deleted, tested in isolation, or reasoned about without reading the whole app.</p><p>There is a second constructor in get_it that almost nobody uses, and it changes the shape of that problem: GetIt.asNewInstance().</p><h3>The problem: dependencies with no owner</h3><p>Here is the version most codebases land on. One container, filled at startup, read from everywhere.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4811645859583507a6f8c2612161c27f/href">https://medium.com/media/4811645859583507a6f8c2612161c27f/href</a></iframe><p>Three things are true about this code, and none of them are visible in it.</p><p>The transfer BLoC is alive from the first time someone opens that screen until the process dies — nothing calls unregister for it. Nothing in the file says which screen owns it. And a widget five levels deep can reach a dependency that its own feature never declared, so the dependency graph of a feature is not written down anywhere — it has to be discovered by grep.</p><p>That third point is the expensive one, and it is worth walking through concretely instead of leaving it as a general complaint, because it shows up as three separate, specific bills.</p><h3>The testing tax</h3><p>Testing TransferScreen in isolation should mean exactly that — isolation. It doesn&#39;t, because the container is one graph, and main() populated every branch of it before the test ever runs.</p><p><strong>Bad:</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/521d122a7cea6032595132b8b761980b/href">https://medium.com/media/521d122a7cea6032595132b8b761980b/href</a></iframe><p><strong>Better:</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8a4700cfa67750fb89fd30f30b62c91d/href">https://medium.com/media/8a4700cfa67750fb89fd30f30b62c91d/href</a></iframe><p>The mock list in the second version is bounded by TransferScope.bridge() — the feature&#39;s own written contract. The mock list in the first version is bounded by nothing. It grows every time <em>any</em> feature in the app adds a dependency that TransferBloc happens to touch transitively, whether or not that dependency has anything to do with transfers.</p><h3>Spaghetti by convenience</h3><p>Developers take the path of least resistance — that isn’t a character flaw; it’s how deadlines work. If someone on the Payment feature needs a piece of profile data and GetIt.I&lt;ProfileBloc&gt;() is sitting right there, globally reachable, they call it. It compiles, the test passes, the ticket closes.</p><p>Six months later Payment depends on Profile’s internal state, nobody decided that on purpose, and the domain boundaries drawn in the architecture diagram are fiction. A global container doesn’t just fail to prevent that shortcut — it’s the thing that makes the shortcut available in the first place. Isolation isn’t a style preference at that point; it’s the only thing standing between the diagram and the code.</p><h3>Zombie dependencies</h3><p>The teardown problem compounds. Forty screens, each leaving behind a BLoC, a StreamSubscriptionsometimes a WebSocket connection, none of it ever disposed because GetIt.instance has no concept of &quot;this feature is done.&quot;</p><p>On a flagship device that’s a memory graph nobody looks at. On a low-end device it’s an OOM crash or a frame drop after twenty minutes of normal use — and the stack trace points at whatever the user happened to be doing when memory ran out, not at the screen from ten minutes ago that never let go of its WebSocket. The leak is global, so the symptom is too; there’s no scope boundary in the crash report to narrow the search.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2F2UCt7zbmsLoCXybx6t%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2Fv1.Y2lkPTc5MGI3NjExbDc1NWhpNTY3ZTFhNGt5N2d6ZGR0cGxwYjFtN3h1NTMydjFlbzh4ZSZlcD12MV9naWZzX3NlYXJjaCZjdD1n%2F2UCt7zbmsLoCXybx6t%2Fgiphy.gif&amp;image=https%3A%2F%2Fmedia2.giphy.com%2Fmedia%2Fv1.Y2lkPTc5MGI3NjExYnZ5bTMwa3pzbzlkMTJxY3IyeGVoN3VmbWJveXBlM2NjejBodTRtMSZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw%2F2UCt7zbmsLoCXybx6t%2Fgiphy_s.gif&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="239" frameborder="0" scrolling="no"><a href="https://medium.com/media/077c3df793b1bf75d407c21378280a78/href">https://medium.com/media/077c3df793b1bf75d407c21378280a78/href</a></iframe><h3>GetIt.asNewInstance() is the whole trick</h3><p>get_it can make containers that are not the singleton. They share nothing with it.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9c2acb5337981f137129505e6c992745/href">https://medium.com/media/9c2acb5337981f137129505e6c992745/href</a></iframe><p>An empty container sounds useless. It is the point. A feature container that inherits nothing has to declare everything it touches, which means the declaration list <em>is</em> the feature’s dependency contract — and a contract can be reviewed, tested, and deleted.</p><h3>Why not pushNewScope()?</h3><p>get_it already ships a scoping mechanism, and it is fair to ask why this article ignores it:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d7a801b811ef04db8a53761c3c88881d/href">https://medium.com/media/d7a801b811ef04db8a53761c3c88881d/href</a></iframe><p>The difference is what “scope” means. pushNewScope() adds a new <em>layer</em> on top of the same GetIt instance. A lookup that misses in the top layer falls through to the layer below it, all the way to the root — every pushed scope can see every prior registration automatically, with no bridge() step and nothing written down. That&#39;s the same leaky abstraction this article is trying to escape, just one call deeper.</p><p>GetIt.asNewInstance() is a different container, not a layer. Nothing falls through — a missed lookup just fails, which forces every dependency to be named explicitly in bridge(). You write the whitelist yourself instead of getting it for free. That&#39;s the trade the rest of this article is about.</p><h3>A scope is a class, not a pile of call sites</h3><p>The empty container needs a lifecycle around it; otherwise every feature invents its own. A small base class is enough: create the container, fill it in a fixed order, tear it down once.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/57f8ff666b11373ec9717de6ec22debe/href">https://medium.com/media/57f8ff666b11373ec9717de6ec22debe/href</a></iframe><p>Two details carry most of the weight. Reading container before init() throws a StateError instead of silently handing back a half-built container, and reset() fires the dispose: callback of every registration in one call — so closing BLoCs and cancelling subscriptions is not something each feature has to remember on its own.</p><h3>bridge() is a whitelist, not an import</h3><p>This is the rule that does the actual work, and it is worth stating as a rule because it is easy to defeat by accident.</p><p><strong>Bad:</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/59affa83cdd78b1ed77cceef3a70b26d/href">https://medium.com/media/59affa83cdd78b1ed77cceef3a70b26d/href</a></iframe><p><strong>Better:</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d1723e3ab0e06bd57ba19f9910e6c0ad/href">https://medium.com/media/d1723e3ab0e06bd57ba19f9910e6c0ad/href</a></iframe><p>Four lines, four dependencies, and a reviewer can see in the diff when a feature starts reaching for something new. A fifth line appearing in a pull request is a conversation. A wholesale forward is not.</p><h3>What a real feature scope looks like</h3><p>Whitelist first, then the feature’s own objects, each with the teardown it needs.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/33e6774fa6a40ada679d263200ecf192/href">https://medium.com/media/33e6774fa6a40ada679d263200ecf192/href</a></iframe><p>Deleting this feature is now deleting this file plus its route entry. No global registration list to prune, and — because nothing else could have bridged into this scope without a corresponding line in its own bridge() — nothing else in the app was quietly depending on AuthBloc either.</p><h3>Binding the scope to the widget tree</h3><p>A scope’s lifetime should be a subtree’s lifetime, so a widget owns it: create oninitState, provide once ready, dispose on unmount.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a3e86ba5b2aa788557221d32b3c27d5b/href">https://medium.com/media/a3e86ba5b2aa788557221d32b3c27d5b/href</a></iframe><p>ScopeProvider is an ordinary InheritedWidget holding a GetIt. Descendants read the <em>nearest</em> container, which is what makes nesting behave: a screen inside a feature sees the feature&#39;s container, not the app&#39;s.</p><h3>The cost: what you’re actually paying for isolation</h3><p>None of this is free, and the price is worth stating plainly instead of discovering it a year in.</p><p><strong>Bridging is manual, and it stays manual.</strong> There is no inheritance and no fallback lookup — that absence is the entire guarantee. It also means a genuinely app-wide dependency (a logger, an AppStorage) gets re-listed in every single scope that touches it. Ten scopes means the same three lines, ten times. That repetition is not an oversight to fix later; it is the isolation, paid in full each time.</p><p><strong>It is not lazy for you.</strong> A scope that registers ten lazy singletons and immediately resolves all of them inside afterInit() has just recreated the global container with extra ceremony.</p><p><strong>init() is not concurrency-safe, and scopes aren&#39;t reusable.</strong> Once disposed, construct a new instance rather than re-init() the old one. Sharing a scope across two subtrees is a bug that only shows up under fast navigation: if the same route can be pushed twice with different arguments (open order #1, then order #2, without popping in between), give ScopeWidget a ValueKey derived from the route argument so Flutter tears down and rebuilds the old scope instead of reusing it.</p><p><strong>Async init means a visible gap.</strong> init() returns a Future, so the subtree needs a placeholder frame while it resolves — a single dropped frame for most screens, a loading state you now have to design for behind an expensive async dependency.</p><p><strong>It does not replace widget-scoped providers.</strong> The container decides <em>who constructs the object and when it dies</em>. BlocProvider And friends still decide who in the widget tree can read it — you still need both.</p><p>The trade being made is explicit: every dependency a feature uses has to be spelled out by hand, twice — once where it’s registered, once where it’s bridged in.</p><h3>Why it’s worth paying</h3><p>The cost of this isolation is paid in upfront typing, whereas the cost of a global locator is paid in debugging memory leaks, unpicking spaghetti dependencies during refactors, and untangling test setups six months later. You have to choose which bill you would rather pay.</p><p>This strictness becomes indispensable the moment your codebase scales beyond a single tight-knit team. If you are building a medium-to-large application with dozens of features, or migrating towards a modular monorepo where features live in their own packages (e.g., package:feature_auth), isolated containers are a way to guarantee a feature is truly decoupled without accidental circular dependencies back to the root app. Furthermore, in environments with rotating feature ownership or high developer turnover, the explicit bridge() list acts as executable documentation. A new engineer never has to guess what a feature relies on to function—they simply read the whitelist. For long-lived projects, trading a little immediate developer convenience for rigorous system maintainability is a trade worth making every single time.</p><h3>A minimal way to see it in isolation</h3><p>You don’t need a real app to feel the difference. Four files are enough: an IsolatedScope base class, a ScopeWidget, a feature scope that bridges exactly one dependency from the root, and a second scope whose parent is the first. Wire up two screens, navigate from one to the other, pop back, and log every dispose() call. The log is the demonstration — objects the global-locator version would have kept alive for the rest of the process instead disappear the moment their screen does.</p><p>If you try this: how many dependencies ended up in your longest bridge() list? Past about six, the honest read is usually that the boundary is in the wrong place — and it would be useful to know whether that number holds for anyone else.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=885b68d786d2" width="1" height="1" alt=""><hr><p><a href="https://levelup.gitconnected.com/flutter-get-it-one-container-per-feature-not-one-global-locator-885b68d786d2">Flutter get_it: One Container Per Feature, Not One Global Locator</a> was originally published in <a href="https://levelup.gitconnected.com/">Level Up Coding</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Migrating to Flutter Without a Rewrite, Part 2: Building a Module That’s Built to Disappear]]></title>
            <link>https://levelup.gitconnected.com/migrating-to-flutter-without-a-rewrite-part-2-building-a-module-thats-built-to-disappear-eca67590b53f?source=rss-8cd4c1cce7e9------2</link>
            <guid isPermaLink="false">https://medium.com/p/eca67590b53f</guid>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[software-architecture]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <dc:creator><![CDATA[Muhammad Rizky]]></dc:creator>
            <pubDate>Fri, 11 Sep 2026 15:22:53 GMT</pubDate>
            <atom:updated>2026-09-11T15:22:53.550Z</atom:updated>
            <content:encoded><![CDATA[<h4>Three strategic decisions, and the architecture inside the module they produced — from a single gateway shipped like an SDK, to two routers nested one inside the other on purpose.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FAqU9cIKLZKLeKEoqFjIJg.png" /></figure><p>Part 1 ended on a promise: choosing Flutter was the easy part.</p><p>The real work was making the migration invisible to users while keeping the transition predictable for the engineers who have to build, test, release, and operate it.</p><p>We defined “invisible” as a set of invariants: authentication and device identity must survive the boundary, security-sensitive capabilities must keep working, navigation and lifecycle must remain coherent, analytics and operational tooling must continue to identify the same product journey, and every migrated feature must remain independently reversible while the migration is in progress.</p><p>This part is about the architecture that makes those invariants possible. Three decisions carry most of the weight. Each one trades something away, but together they give us a migration boundary that can exist for months without becoming the architecture we have to live with forever.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*q097ErPQueEXYK6DzpcxFA.png" /></figure><h3>Decision 1: One gateway, one contract</h3><p>For our Add-to-App setup, we chose to consume a single Flutter module as the migration boundary. That still left the decisions that mattered.</p><p>One platform channel, or a channel per feature? Features as routes in one codebase, or independently versioned packages that only meet at build time? One Dart entry point, or one per flow?</p><p>A single module can still be fragmented internally into exactly the coordination problems we are trying to remove. We chose to minimize the integration surface: a single Flutter gateway module containing every migrated feature as internal routes behind one channel contract, paired with thin native entry activities — one small Kotlin module per feature on the host side.</p><p>Each entry activity does exactly three things:</p><ol><li>Spin up a Flutter engine,</li><li>Push configuration across the platform boundary,</li><li>Tell Flutter which route to open.</li></ol><p>Nothing else lives there. No business logic. No feature state. No duplicated navigation logic beyond telling Flutter which entry point to open and receiving the result back.</p><p>Part 1 showed the module-level direction: native feature implementations are gradually retired in favor of thin Flutter host modules. What that diagram doesn’t show is what backs the “one contract” half of the claim. It isn’t just a convention.</p><p>There is exactly one MethodChannel, initialized once, with a chain-of-responsibility list of feature-scoped handlers registered at startup:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/333f65ae385174171f4b7e0cf7c75e22/href">https://medium.com/media/333f65ae385174171f4b7e0cf7c75e22/href</a></iframe><p>Adding a feature to the migration is adding one handler to that list — not wiring a new channel, not touching the ones that already exist:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/636e200593d41d6c33c07efa32fba73e/href">https://medium.com/media/636e200593d41d6c33c07efa32fba73e/href</a></iframe><p>That’s the entire integration surface for a new feature, on the Flutter side: one class, oneswitch, one route. The corresponding native activity is symmetrically small — it exists to launch the engine and get out of the way, not to reimplement anything. (What crosses that channel at runtime — session tokens, config, the handshake sequence — is deliberately out of scope here; that&#39;s a later part&#39;s subject, once the bridge itself is under discussion rather than the shape of the module.)</p><p><strong>What happens to the native implementation?<br></strong>Once its Flutter replacement ships, the old native feature does not disappear immediately. Its lifecycle is:</p><blockquote><strong>Active → Flutter replacement monitored → native implementation frozen → rollback target → deleted.</strong></blockquote><p>The old implementation continues receiving critical fixes while the Flutter version is under production monitoring.</p><p>Only after the Flutter feature is considered safe do we freeze the native implementation. From that point forward, it exists as a rollback target rather than as an actively developed implementation.</p><p>This matters because rollback is only useful if the thing you’re rolling back to is still trustworthy.</p><p>The double-maintenance window is therefore deliberate and bounded. It ends based on a production-safety decision rather than an arbitrary calendar date.</p><p><strong>Why consolidation wins for a migration</strong> (as opposed to a greenfield multi-team product):</p><ul><li><strong>One bridge to test.</strong> Every native↔Flutter call goes through one MethodChannel and its handler chain — not N contracts drifting apart, the same disease we were curing.</li><li><strong>Features share everything by default.</strong> Design system, networking, storage, session — inside one module they’re ordinary imports; across modules they’d be integration work.</li><li><strong>The endgame is one app.</strong> A per-feature module fleet would need merging <em>back</em> into one — scheduling a second migration at the end of the first.</li></ul><p>The trade-off is honest: a single module means a single version, so every feature rides the same release train, and the module’s build grows with every migrated feature. For our team and release cadence, that coupling was acceptable because it kept the Flutter side aligned with the existing product release cycle while keeping the integration boundary small.</p><h3>Decision 2: Ship the module as a versioned artifact, not as source</h3><p>Flutter’s Add-to-App workflow allows the module to be built alongside the host or consumed as compiled artifacts. We chose the latter. The Android side consumes Flutter as AARs published to an internal Maven repository, pinned through the Gradle version catalog much like a third-party SDK:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/dbab3a8c2bebe608fe086c4e226ce661/href">https://medium.com/media/dbab3a8c2bebe608fe086c4e226ce661/href</a></iframe><p>This decision separated the Flutter build environment from the native host environment.:</p><ul><li><strong>Native engineers never install Flutter.</strong> No SDK, no Dart toolchain, no flutter doctor in the Android team&#39;s onboarding. The Flutter module arrives in their build exactly the way a payment SDK does. Adoption friction on the host team dropped to zero.</li><li><strong>Rollback is a one-line diff.</strong> The version catalog pins each environment to an exact artifact version with Gradle’s strictly(). A bad Flutter release in production? Revert one line inlibs.versions.toml, rebuild, ship. No revert-the-merge archaeology across two repos.</li><li><strong>Environments are explicit.</strong> Production pins a stable version, while development can float against a continuously published development artifact so feature branches can integrate against the latest Flutter work. Debug and release AARs are wired per build type across the host application’s product flavors.</li><li><strong>Clean team boundary.</strong> The Flutter team releases like an SDK vendor: build, version, publish, changelog. The native team consumes. Responsibility for a regression is legible from the version bump that introduced it.</li></ul><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2F1BFxCACn4LQJi4HPWv%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2Fv1.Y2lkPTc5MGI3NjExaHBtY3hwdzlsem1yNWRnOTdoYXNoY3BmbXAzbXFrZnA2enV6MzBuZCZlcD12MV9naWZzX3NlYXJjaCZjdD1n%2F1BFxCACn4LQJi4HPWv%2Fgiphy.gif&amp;image=https%3A%2F%2Fmedia1.giphy.com%2Fmedia%2Fv1.Y2lkPTc5MGI3NjExenhuNTI3NDMzeXoxdHBuNmFkanpnaXg4aDdpZGEwbmtxNTFxaTM1MiZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw%2F1BFxCACn4LQJi4HPWv%2Fgiphy_s.gif&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="244" frameborder="0" scrolling="no"><a href="https://medium.com/media/4358a776b051022f240225acca59e258/href">https://medium.com/media/4358a776b051022f240225acca59e258/href</a></iframe><p>The cost: iteration across the boundary is slower. Changing a channel contract means publish-then-bump instead of one atomic commit, and the two sides of the bridge live in different repos with different reviewers. A standalone debug mode compensates for a lot of this — worth a full explanation later in the series, alongside how we test and roll out hybrid releases.</p><h3>Decision 3: Build the exit ramp on day one</h3><p>The most consequential decision doesn’t show up in any Gradle file. It’s in the Flutter module’s lib/ layout:</p><pre>lib/<br>├── app/        # the future full Flutter app: go_router, DI, features, startup<br>├── gateway/    # the add-to-app shell: channel handlers, native-facing routes<br>└── main.dart   # standalone / full-app entrypoint</pre><p>The module has two runtime environments but one feature architecture.</p><p>gateway/ is everything that exists <em>because</em> we&#39;re embedded in a native host: the method-channel plumbing, per-feature handlers, and a plain-Navigator routing shell that native drives.</p><p>app/ is the application we&#39;re actually building: features, go_router, dependency injection, startup — written as if the native host were already gone. (Yes, that means two routers live in one codebase on purpose — go_router for the app that&#39;s coming, Navigator for the shell that exists only until it arrives. More on that nesting shortly.)</p><p>A LaunchResolver decides at startup which world we&#39;re in — embedded in native, running standalone for development, or (one day) running as the full app — and wires dependencies accordingly.</p><p>Capabilities that still live in native, such as authentication, sit behind an interface with two implementations:</p><ul><li>one that calls through the platform channel,</li><li>one implemented entirely in Dart.</li></ul><p>Swapping them is a provider override rather than a feature refactor.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f099a5cbef3f53da4b5c959284b7512b/href">https://medium.com/media/f099a5cbef3f53da4b5c959284b7512b/href</a></iframe><p>That provider is the actual migration seam. A feature depends on the <em>interface</em> authenticationInvokeMethodProvider and never branches on</p><blockquote>“am I embedded?”</blockquote><p>It simply receives whichever implementation LaunchResolver configured at startup. Behind the interface sit two of them. Take &quot;a login just completed&quot;:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/09fac74af612d8606158d658409a634c/href">https://medium.com/media/09fac74af612d8606158d658409a634c/href</a></iframe><p>The feature calls closeLogin(result) and never knows which of these runs. The <em>default</em> provider is the channel implementation — because embedded is today&#39;s reality — and provideOverrides() swaps in the Flutter one only when there&#39;s no native host. The day the native host disappears, LaunchResolver changes; the features that consume it don&#39;t.</p><p><strong>Where the toggle actually fires.</strong> provideOverrides() is read in exactly one place — the module&#39;s rootProviderScope, inside mainApp():</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/66d760e9d90f9f04844ebd4c7ac7ca58/href">https://medium.com/media/66d760e9d90f9f04844ebd4c7ac7ca58/href</a></iframe><p>Both run modes reach this same function. Standalone calls mainApp() directly from main(); embedded gets there one hop later, when a gateway route boots mainApp() for the feature native asked for (that nesting is the routing section&#39;s subject, below). Either way, mainApp() — and its one ProviderScope — runs. There is no &quot;embedded path with no ProviderScope&quot;; there&#39;s one override site both doors arrive at.</p><p>What differs is only what provideOverrides() <em>returns</em>. Embedded, it returns [] — because the default implementation behind each provider is already the channel-backed one, so there&#39;s nothing to swap. The overrides only carry weight when there&#39;s no native host at the other end: standalone debug, or the eventual full app. That&#39;s exactly why the flip works: the &quot;no native host&quot; wiring isn&#39;t invented at migration time — it already runs every day in debug. Full migration just makes it the only case.</p><p>The principle: <strong>add-to-app is a transition state, and the code should know it.</strong> When the last native screen falls, the flip is: stop building AARs, start building an app — gateway/ gets deleted, app/ gets promoted, and no feature code moves.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FbRKM4yqBFJ5JQEsxRr%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2Fv1.Y2lkPWVjZjA1ZTQ3a3M4bW9wZ2d3aTZqY2hnMDlvOWQ0MW11NzlxamR5Zmc3dmczMzg0byZlcD12MV9naWZzX3NlYXJjaCZjdD1n%2FbRKM4yqBFJ5JQEsxRr%2Fgiphy.gif&amp;image=https%3A%2F%2Fmedia1.giphy.com%2Fmedia%2Fv1.Y2lkPTc5MGI3NjExMjV6b3kwcW83cmFqd25taXBucHpjcjdtcmw0ZWI4ZXVhNTdrcXN2ZiZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw%2FbRKM4yqBFJ5JQEsxRr%2Fgiphy_s.gif&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="313" frameborder="0" scrolling="no"><a href="https://medium.com/media/717c34c76fac4e1033cea4dcf2b5b2d2/href">https://medium.com/media/717c34c76fac4e1033cea4dcf2b5b2d2/href</a></iframe><p>Without this split, the natural gravity of add-to-app pulls every feature into coupling with the bridge — and the “temporary” hybrid architecture becomes the permanent one.</p><h3>What we explicitly rejected</h3><p>For completeness, the strategies we considered and dropped:</p><ul><li><strong>Big-bang rewrite</strong> — ruled out in Part 1: no feature freeze, no user disruption, no compliance regression. A parallel rewrite of a monthly-shipping regulated app is a bet that nothing changes for a year. Everything changes every month.</li><li><strong>New features in Flutter, old features stay native forever</strong> — the “strangler fig without the strangling” pattern. It caps the payoff: you keep both codebases and both teams indefinitely, which is the tax we set out to eliminate.</li><li><strong>A fragmented single module</strong> — per-feature channels, per-feature entrypoints, independently versioned feature packages meeting only at build time. Technically possible inside the one-module constraint, but it rebuilds the coordination problem we were escaping — and the endgame is one app anyway.</li><li><strong>Building the host from Flutter source</strong> — couples native CI to the Flutter toolchain and gives up the one-line rollback. The AAR pipeline cost us a week of setup and has been repaying it monthly.</li></ul><h3>Inside the module: the architecture those decisions produced</h3><p>Three decisions gave the migration its shape: one gateway, distributed like an SDK, built to know it’s temporary. Now let’s look at what runs inside that shape — how routing actually works in a module with two personalities, the full request path from a native tap to a stored session, and the short checklist that migrating one feature comes down to.</p><h3>Two routers, nested on purpose</h3><p>The gateway/ vs app/ split extends into navigation, and this is the part that surprises people: the module runs <strong>two routers at once — one inside the other</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/566/1*ECe93Eb1RWBGkvIxUfrRNA.png" /><figcaption><strong>A Navigator hosting a go_router app. Yes, we heard ourselves.</strong></figcaption></figure><p>app/ is the real application. It owns every feature, routed by go_router (URL reflection on, for the deep links and history a standalone app will need).</p><p>gateway/ is the embedded shell. It uses a plain Navigator.</p><p>The thing to understand is what the gateway’s routes actually do: <strong>they don’t render features.</strong> Each one boots the app. A gateway route builder returns EntryPointInitPage(initPage: mainApp(initialLocation: &lt;feature&gt;)) — it mounts the entire go_router app, rooted at the feature native asked for:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/519dacdc5068486125b391222a0ce808/href">https://medium.com/media/519dacdc5068486125b391222a0ce808/href</a></iframe><p>So there is no second implementation of any feature. The gateway Navigator is an outer shell whose entire job is to launch the inner go_router app at a chosen entry point, on the native&#39;s command. Features are written once, inapp/; the gateway just points at them. That&#39;s why &quot;which router&quot; is never a branch inside feature code — the outer shell hands off to the inner app and gets out of the way.</p><p>You’ve already seen the inner end — mainApp(), from Decision 3, which builds MaterialApp.router on a go_router config. The outer shell is just as small:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a82c3f32e40a9c3ffc0e4138c13b2331/href">https://medium.com/media/a82c3f32e40a9c3ffc0e4138c13b2331/href</a></iframe><p>The cost is real: two routing models to hold in your head, and route names duplicated across the outer shell and the inner app kept in sync by convention, not the compiler. We keep it because the outer shell is temporary scaffolding — when native is gone, gateway/ is deleted and only go_router remains. Forcing URL semantics onto a throwaway shell, or making the future app inherit a shell router it will outgrow, both seemed worse than the nesting.</p><h3>The full path, end to end</h3><p>Every decision so far has been introduced on its own. It’s worth watching them run together, because the wiring only really makes sense as a sequence. Here’s a single login, embedded in the native app, from tap to session — each step is a piece you’ve already met:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AwV-olGpbfUkzggK7xWdeg.png" /></figure><ol><li><strong>The user taps “login” in the native app.</strong> A thin native entry activity asks the shared FlutterEngineGroup for an engine (Decision 1) and launches it into the custom Dart entrypoint, initializeChannelConfig — not main().</li><li><strong>The entrypoint wires the bridge, nothing else.</strong> It registers every feature’s BaseMethodHandler on the one channel (Decision 1) and initializes LaunchResolver (which decides run mode). No UI yet.</li><li><strong>Native pushes config, then says go.</strong> Over the channel, native sends its whole config payload — base URLs, keys, device identity, session material — which Flutter stores; only <em>then</em> does native call start_app. That ordering is deliberate (Flutter must be able to read config before the first widget builds), and it&#39;s also where the honest delay(1500) lives — native waits a fixed beat for Dart to be ready, a race we&#39;ll dissect in Part 3.</li><li><strong>start_app boots the outer shell.</strong> The handler for it calls runApp(GatewayApp()) — the thin Navigator shell. Still no feature on screen; just the shell showing a loading page.</li><li><strong>Native asks for a specific feature.</strong> It calls navigate_to_login on the channel. The authentication handler pushes the gateway&#39;s login route — whose builder boots mainApp() at the login entry point (Decision 3 / the routing section). The inner go_router app now owns the screen.</li><li><strong>The feature runs, oblivious to run mode.</strong> The login UI reads its config from CommonAppConfig (the payload from step 3) and its behavior from authenticationInvokeMethodProvider — which, embedded, resolves to the channel-backed implementation, because that&#39;s the default and provideOverrides() returned [].</li><li><strong>Login completes, and the session crosses back.</strong> The feature calls closeLogin(result). The channel-backed implementation forwards the result over the channel to native, which persists it in the session store the native app already owns. No second login, no divergent state.</li></ol><p>Now delete the native host in your head and re-read. Steps 1–5 vanish. Step 6’s provider default flips — via the override already sitting in LaunchResolver — to the pure-Dart implementation, so step 7 becomes SessionManager.saveCredential(...) plus a go_router navigation instead of a channel call. Every other line is identical. That&#39;s the whole point of the wiring: the same feature code runs in both worlds, and the seams decide which world it&#39;s in.</p><h3>What migrating a feature actually touches</h3><p>Putting it together, migrating one feature comes down to five moves:</p><ul><li><strong>Freeze new development on the native feature implementation once the Flutter version is live and under production monitoring.</strong> Keep the native code as a rollback target until the Flutter implementation has passed the agreed safety criteria.</li><li><strong>Add a thin native host module and entry activity.</strong> Engine, configuration, route. Nothing else.</li><li><strong>Add one feature handler to the existing channel chain.</strong> No new channel and no separate bridge integration.</li><li><strong>For any capability that differs between embedded and standalone runtime, define an interface with the required implementations.</strong> Default the provider to the native-backed implementation and let LaunchResolver supply the pure-Dart implementation when running without the native host.</li><li><strong>Add a gateway route that boots </strong><strong>mainApp() at the feature&#39;s entry point.</strong> The feature itself is implemented once inside app/.</li></ul><p>The migration should not require changes to features that have already completed migration. Shared infrastructure can still evolve, and bridge or contract changes still need normal regression testing, but a new feature should not create another dependency on the migration machinery.</p><p>Operational continuity is part of the migration too. Analytics, logging, crash reporting, feature flags, and rollout controls need to continue identifying the migrated flow as part of the same product journey. And the native team should only need to consume a new Flutter artifact version rather than understand the implementation inside the module.</p><h3>What’s next</h3><p>The strategy explains why this shape exists. The architecture explains what’s running inside it.</p><p>What we haven’t shown yet is what happens the moment a user actually crosses the boundary — because a gateway and a channel contract are only half the story until something real moves across them: a fresh engine spinning up mid-tap, a session token that has to survive the handoff, and a hard-coded delay(1500) in the handshake that we are still, to this day, not proud of.</p><p>Part 3 is that story — plus how we test and roll out hybrid releases without a monthly game of production roulette, and what two years of this has actually bought us.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=eca67590b53f" width="1" height="1" alt=""><hr><p><a href="https://levelup.gitconnected.com/migrating-to-flutter-without-a-rewrite-part-2-building-a-module-thats-built-to-disappear-eca67590b53f">Migrating to Flutter Without a Rewrite, Part 2: Building a Module That’s Built to Disappear</a> was originally published in <a href="https://levelup.gitconnected.com/">Level Up Coding</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How We’re Migrating a 1M+ Install Finance App from Native to Flutter — Without a Rewrite Part 1]]></title>
            <link>https://levelup.gitconnected.com/how-were-migrating-a-1m-install-finance-app-from-native-to-flutter-without-a-rewrite-part-1-240aaf3cd062?source=rss-8cd4c1cce7e9------2</link>
            <guid isPermaLink="false">https://medium.com/p/240aaf3cd062</guid>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[software-architecture]]></category>
            <category><![CDATA[ios]]></category>
            <dc:creator><![CDATA[Muhammad Rizky]]></dc:creator>
            <pubDate>Fri, 11 Sep 2026 15:15:06 GMT</pubDate>
            <atom:updated>2026-09-11T15:15:06.009Z</atom:updated>
            <content:encoded><![CDATA[<h4>An incremental Add-to-App migration of a production consumer-finance app: the decisions, the trade-offs, and the code that makes two worlds share one session.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FAqU9cIKLZKLeKEoqFjIJg.png" /></figure><p>Two years ago, our team was shipping the same feature twice. Every credit-application flow, every payment screen, every regulatory change landed in two backlogs: once in Swift, once in Kotlin. Two codebases, two teams, two review pipelines — and, inevitably, two slightly different apps pretending to be one product.</p><p>This series is about how we’re fixing that — and it’s not the way most migration stories go. There was no rewrite. There was no feature freeze. We’re moving a production consumer-finance app — over a million installs, operating under national financial-regulatory oversight, handling credit applications, collateral-based loan disbursement, installment payments, and a rewards-and-commerce ecosystem — to Flutter one feature at a time, with Flutter embedded <em>inside</em> the existing native apps. Users kept transacting through every release. Most will never know a migration happened.</p><p>This is written for engineers who already ship mobile apps. I won’t explain what a widget is. I will, over the course of this series, explain why we run two routing systems in one module on purpose.</p><h3>Where we’re going</h3><p>Most Flutter Add-to-App examples focus on embedding Flutter into an existing app. Our challenge began after Flutter was already running. We weren’t integrating a single feature — we were planning a months-long migration of an entire production application.</p><p>Instead of asking:</p><blockquote>“How do we launch Flutter from native?”</blockquote><p>we asked a different question:</p><blockquote>“How do we make Flutter behave like just another native feature while the migration is still in progress?”</blockquote><p>That single question shaped almost every architectural decision that followed. The result was an architecture that looks surprisingly different from most Add-to-App examples.</p><p>Before we explain why each decision was made, here’s the overall shape of what we built. Every piece below is a deliberate trade-off — none of it is how the standard Add-to-App tutorial does it.</p><ul><li><strong>One gateway, used to its full extent.</strong> A host app can only embed a single Flutter module — the toolchain doesn’t offer “one module per feature” as an option. Most add-to-app examples treat that one module as a single embedded feature. We treated it as the backbone of an entire migration: every migrated flow as a route behind one platform-channel contract, instead of fragmenting internally into per-feature channels and entry points. That decision simplified versioning, reduced integration work, and scaled to dozens of features without dozens of contracts.</li><li><strong>Flutter is consumed like any other internal SDK.</strong> Native engineers don’t clone the Flutter repository or install the Flutter SDK. They simply update a Maven dependency. If a Flutter release goes wrong, rolling back is a one-line version change.</li><li><strong>Every migrated flow starts with a fresh Flutter engine.</strong> Rather than keeping one long-lived engine alive for the entire app, we create isolated engines from a shared FlutterEngineGroup, each launched into a custom Dart entry point instead of main().</li><li><strong>Crossing the native–Flutter boundary doesn’t interrupt the user’s journey.</strong> Authentication tokens, device identity, and cryptographic keys move across the platform boundary, allowing users to continue their existing session without ever seeing another login screen.</li><li><strong>The migration already contains its own endgame.</strong> The Flutter module isn’t just embedded inside the native app — it is designed to eventually become the app itself. When the final native screen disappears, the architecture doesn’t change. The host does.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MFnq9d96sDR477eW_xEuiQ.png" /></figure><p>Part 1 covers why we chose this path at all. The architecture above is what Parts 2 and 3 unpack — and, because no honest migration story is complete without them, the gotchas, including the hard-coded delay(1500) we&#39;re not proud of.</p><h3>The problem: one product, two apps</h3><p>On paper we had one app. In practice we had two mature, diverging products — and the failure mode wasn’t dramatic. It was drift.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nesly6MagGW6v5UYffAr1w.png" /></figure><ul><li><strong>Feature divergence.</strong> A flow would ship on Android first; iOS would catch up a release or two later — or implement it subtly differently. Support tickets started including the question “which phone do you have?”</li><li><strong>Double maintenance.</strong> One product requirement meant two implementations, two sets of edge cases, two QA passes.</li><li><strong>Compliance amplification.</strong> In a regulated finance product, an auditor’s finding isn’t fixed until it’s fixed <em>on both platforms</em>. Every security patch had double the surface area and double the verification burden.</li><li><strong>Team economics.</strong> Two platform teams, two rare skill sets to hire and retain — and the effective feature throughput of one team.</li></ul><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FNTur7XlVDUdqM%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2Fv1.Y2lkPTc5MGI3NjExOHI4bmI0bXFobzJ5bXVjNzgyZm03OXpiOGU2ZGZ4ZTZrNG1vYjdjbCZlcD12MV9naWZzX3NlYXJjaCZjdD1n%2FNTur7XlVDUdqM%2Fgiphy.gif&amp;image=https%3A%2F%2Fmedia0.giphy.com%2Fmedia%2Fv1.Y2lkPTc5MGI3NjExaGhsZXIyemVtdXM3MWlxb2k4NWV3OW5yYjJpdWloNmd2aDZ6NjF5cCZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw%2FNTur7XlVDUdqM%2Fgiphy_s.gif&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="244" frameborder="0" scrolling="no"><a href="https://medium.com/media/36927fd389bbebb3414d64faa0b9a015/href">https://medium.com/media/36927fd389bbebb3414d64faa0b9a015/href</a></iframe><p>None of this was necessarily catastrophic on any individual release. The problem was accumulation. Every new initiative had to account for the cost of implementing, testing, reviewing, and maintaining the same behavior twice. Feature parity became something we continuously worked toward instead of something the architecture naturally gave us.</p><h3>The rules we couldn’t break</h3><p>The fix seems obvious — one cross-platform codebase, one implementation per feature, parity by construction. But “rewrite the app” is a very different proposition when the app is a bank-adjacent product with a million users mid-loan. Three constraints were non-negotiable:</p><ul><li><strong>No user-facing disruption.</strong> People have active loans, due dates, and payment autodebits in this app. “Please reinstall and log in again” was not an acceptable release note.</li><li><strong>No feature freeze.</strong> The business would not pause a competitive lending product for 12–18 months. The migration had to happen <em>while</em> monthly releases continued.</li><li><strong>No compliance regression.</strong> Secure storage, device binding, liveness checks, audit trails, and other security-sensitive capabilities already relied upon by the product had to keep working throughout the migration.</li></ul><p>These constraints ruled out the big-bang rewrite before implementation began. Whatever architecture we chose had to coexist with the existing native application for months on end. The migration therefore had to satisfy a more difficult requirement than simply “the Flutter version works”: <strong>The old and new implementations had to coexist without changing the user’s application session.</strong></p><h3>What we were starting from</h3><p>The starting point was not a greenfield application. The Android and iOS applications had accumulated years of product behavior, platform integrations, and business rules. Their implementations were also organized around their respective native ecosystems, which meant that the same product capability could have different boundaries, lifecycle assumptions, and integration details on each platform.</p><p>Every feature we migrated therefore had two jobs. First, it had to reproduce the existing product behavior. Second, it had to establish a new shared implementation that could eventually replace both native versions. That distinction mattered.</p><p>We weren’t simply rebuilding screens in Flutter. We were moving ownership of product behavior from two platform implementations into one shared implementation while keeping the existing application operational.</p><h3>Why Flutter</h3><p>Our decision was driven primarily by the shape of the migration rather than by a desire to replace native development for its own sake.</p><p>We needed a framework that could:</p><ol><li><strong>Run incrementally inside the existing production applications.<br></strong>The first Flutter feature could not depend on the rest of the application already being Flutter. Native screens had to continue working normally before, during, and after the migration.</li><li><strong>Give migrated features a single implementation.<br></strong>Once a feature moved, its UI and application behavior should have one primary implementation instead of maintaining separate platform versions.</li><li><strong>Give us control over the rendered UI.<br></strong>We wanted migrated screens to behave consistently across Android and iOS rather than requiring platform-specific implementations for ordinary UI behavior.</li><li><strong>Fit the skills of the engineers already responsible for the product.<br></strong>The migration would be carried by engineers who already understood the domain, existing application behavior, security requirements, and years of product edge cases.</li><li><strong>Produce a clean deployment boundary.<br></strong>The native applications needed to consume Flutter as a versioned artifact. This allowed the Flutter side to evolve independently enough for incremental migration while keeping the host applications in control of when a new Flutter version was adopted.</li></ol><p>The important point is that we were not selecting a framework for a greenfield app. We were selecting a migration mechanism.</p><p>Flutter’s Add-to-App workflow gave us the primitives we needed: a Flutter module embedded in an existing native application, versioned artifacts consumed by the native build, shared engine infrastructure, and custom Dart entry points for individual flows.</p><p>That made the architecture fit the migration constraint rather than forcing the migration to fit the architecture.</p><h3>The trade-offs we accepted</h3><p>We chose Flutter with our eyes open — we hit every one of these:</p><ul><li><strong>Binary size.</strong> The Flutter engine adds real megabytes to apps that were already large. For an iOS app around 330 MB, that was a genuine cost we accepted, not a rounding error.</li><li><strong>Memory.</strong> Every running engine has a footprint. Our design spins up a fresh engine from a shared FlutterEngineGroup each time a user enters a migrated flow and destroys it on exit — trading startup cost and memory churn for state isolation. You feel that trade on low-end Android devices, which for a lending product in our market is a meaningful share of users. (The full engine lifecycle is in Part 3.)</li><li><strong>Two hiring pools during transition.</strong> For as long as the migration runs — months of hybrid releases — we need native experts <em>and</em> Flutter engineers. The team-cost savings arrive at the end, not the beginning. Budget accordingly.</li><li><strong>The bridge is a tax.</strong> Every capability that stays native — biometrics, secure storage, payment SDKs, push — becomes a platform-channel contract to design, version, and test on both sides. Add-to-App doesn’t remove native work; it concentrates it into an interface.</li></ul><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2F3ztiZa4eICWGs%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2Fv1.Y2lkPTc5MGI3NjExcTRyMnNkbDVkejBtdDdta3dwcHZoMTNwbGw5cjljenVuazVla3UzZiZlcD12MV9naWZzX3NlYXJjaCZjdD1n%2F3ztiZa4eICWGs%2Fgiphy.gif&amp;image=https%3A%2F%2Fmedia0.giphy.com%2Fmedia%2Fv1.Y2lkPTc5MGI3NjExZmI3Zmg0NTJtbzBjYTU2bHlkbWlhOGJjMm9wODVzOTJlZG4wamRvbCZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw%2F3ztiZa4eICWGs%2Fgiphy_s.gif&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="435" frameborder="0" scrolling="no"><a href="https://medium.com/media/7089fee723227a7e437cab6fb4008a13/href">https://medium.com/media/7089fee723227a7e437cab6fb4008a13/href</a></iframe><p>These were acceptable because they were explicit trade-offs against the constraints we could not break. The goal was never to pretend that Flutter eliminated platform complexity. The goal was to move the complexity to a boundary we could control.</p><h3>What’s next</h3><p>Choosing Flutter turned out to be the easy part. The real challenge was making the migration invisible. “Users shouldn’t notice” is a useful goal, but it isn’t specific enough to engineer against. We defined invisibility as a set of invariants that had to remain true while ownership moved from native to Flutter:</p><ul><li><strong>Authentication continuity.</strong> A user entering a Flutter flow must remain in the same authenticated session. No second login, token re-entry, or unexpected session reset.</li><li><strong>Device identity continuity.</strong> Device binding and other device-level identifiers must remain consistent across the native and Flutter portions of the application.</li><li><strong>Security continuity.</strong> Secure storage, cryptographic material, biometric capabilities, liveness checks, and other security-sensitive integrations must preserve their existing behavior across the boundary.</li><li><strong>Navigation continuity.</strong> Moving from native into Flutter and back must behave like normal application navigation. Back actions, completion, cancellation, and deep-link-driven flows must not leave the user in an unexpected navigation state.</li><li><strong>Lifecycle continuity.</strong> Backgrounding, resuming, termination, and recreation must not introduce a second application lifecycle model that the product has to reason about separately.</li><li><strong>Analytics continuity.</strong> A migrated screen should remain part of the same product journey. Events, identifiers, and business outcomes must remain attributable across the native–Flutter boundary.</li><li><strong>Operational continuity.</strong> Crash reporting, logging, feature flags, and rollout controls must continue to work regardless of which side owns the current screen.</li><li><strong>Release continuity.</strong> A Flutter feature must be independently releasable without requiring the rest of the application to migrate at the same time.</li></ul><p>These invariants became more important than the framework itself.</p><p>If a user can move from a native screen to a Flutter screen without noticing a different session, navigation model, security model, or product journey, then the migration is doing its job.</p><p>QA shouldn’t need a fundamentally different test strategy simply because a screen happens to be written in Flutter. Native engineers shouldn’t need to care whether the next feature comes from a native module or a Flutter module.</p><p>The architecture should make the implementation boundary visible to engineers, but invisible to users.</p><p>The rest of the series unpacks how we enforce those boundaries in code.</p><p><strong>Part 2 — The strategy and the architecture.</strong></p><ul><li>Why we built a single Flutter Gateway instead of one module per feature — shipped to native teams as a versioned Maven artifact, no Flutter SDK required.</li><li>What happens to native code once its Flutter replacement ships — and how the module was designed from day one to eventually <em>become</em> the app.</li><li>Why one codebase deliberately runs two routing systems, and the Riverpod provider override that decides, at startup, whether a capability lives in Dart or across the bridge.</li></ul><p><strong>Part 3 — The bridge, and shipping it.</strong></p><ul><li>Why every migrated flow starts from a fresh FlutterEngineGroup engine, and how sessions, cryptographic keys, and device identity cross the native–Flutter boundary without a second login.</li><li>How we test, stage, and roll out hybrid releases without production regressions — and what the migration has actually bought us so far.</li><li>Plus the story behind the hard-coded delay(1500) that survived far longer than we&#39;d like to admit.</li></ul><p>Building the architecture wasn’t the difficult part. Making it feel invisible was. That’s where Part 2 begins.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=240aaf3cd062" width="1" height="1" alt=""><hr><p><a href="https://levelup.gitconnected.com/how-were-migrating-a-1m-install-finance-app-from-native-to-flutter-without-a-rewrite-part-1-240aaf3cd062">How We’re Migrating a 1M+ Install Finance App from Native to Flutter — Without a Rewrite Part 1</a> was originally published in <a href="https://levelup.gitconnected.com/">Level Up Coding</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[One Pipe for Every Side Effect: How Our Flutter BLoCs Fire Toasts, Dialogs, and Navigation Without…]]></title>
            <link>https://levelup.gitconnected.com/one-pipe-for-every-side-effect-how-our-flutter-blocs-fire-toasts-dialogs-and-navigation-without-d4c35c28fb16?source=rss-8cd4c1cce7e9------2</link>
            <guid isPermaLink="false">https://medium.com/p/d4c35c28fb16</guid>
            <category><![CDATA[flutter-state-management]]></category>
            <category><![CDATA[software-architecture]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[flutter-app-development]]></category>
            <category><![CDATA[mobile-development]]></category>
            <dc:creator><![CDATA[Muhammad Rizky]]></dc:creator>
            <pubDate>Tue, 08 Sep 2026 15:29:29 GMT</pubDate>
            <atom:updated>2026-09-08T15:29:29.160Z</atom:updated>
            <content:encoded><![CDATA[<h3>One Pipe for Every Side Effect: How Our Flutter BLoCs Fire Toasts, Dialogs, and Navigation Without Touching BuildContext</h3><h4>In our shared Flutter platform, a BLoC never calls Navigator.push or ScaffoldMessenger.showSnackBar directly. Every one-shot UI action — a snackbar, a dialog, four different kinds of navigation — is instead emitted as plain data and carried out by one shared listener. Here&#39;s the side-effect pattern, the naive version of it that quietly eats a repeated error message, and the one trick that keeps it from happening.</h4><p>Six kinds of one-shot UI action exist in our shared Flutter platform: show a snackbar, show a dialog, and four flavors of navigation — go, push, replace, pop. Every one is handled by exactly one widget and one registry. Not a single BLoC calls Navigator.push, ScaffoldMessenger.of(context).showSnackBar, or anything else needing a BuildContext, directly. A BLoC emits a value describing what should happen, and something else — registered once, at startup — makes it happen.</p><p>That’s the whole idea: a “side effect” — show this, navigate there — is not a method call, it’s data, the same way the BLoC’s visible state is data. That sounds like a small distinction until you build it, because the moment a one-shot action lives <em>on</em> your state object, it inherits everything your state-management library does to states — including the parts you didn’t want.</p><h3>The plan that looks obviously right</h3><p>Say you’re modeling a failed sign-in. The BLoC already has a state object; the natural move is to give it a field for what went wrong:</p><pre>// The tempting first draft — an action, stored as inert data on state.<br>class AuthUnauthenticated extends AuthState {<br>  const AuthUnauthenticated({this.errorMessage});<br>  final String? errorMessage;<br>}</pre><p>A widget listens for errorMessage and shows a snackbar when it&#39;s non-null. It works the first time. Then picture a user typing the same wrong password twice in a row:</p><pre>// Same shape as the real sign-in<br>// handler, with the action modeled as a plain field instead of an effect.<br>try {<br>  final result = await _authRepository.signIn(email: event.email, password: event.password);<br>  emit(AuthAuthenticated(result));<br>} on Failure catch (failure) {<br>  emit(AuthUnauthenticated(errorMessage: failure.message));<br>}</pre><p>Two calls to emit(), two AuthUnauthenticated states, identical message both times. That should be harmless — except flutter_bloc&#39;s emit() compares the new state to the current one and does nothing if they&#39;re equal. Exactly the behavior you want when a BLoC re-emits an unchanged loading state. Exactly the behavior you don&#39;t want here: two states with the same errorMessage are, as far as Equatable is concerned, the same state, so the second emit() is silently swallowed. The user who fails twice in a row sees an error toast exactly once.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*TZerFXBbPKSu0pILnX8FFg.jpeg" /><figcaption><em>Login attempt #2, from the user’s side: no toast, no spinner, no anything. The action was real data on the state — which is exactly the problem.</em></figcaption></figure><p>The deeper issue isn’t the toast — it’s that “an action that must run” and “a value that describes the screen” got treated as the same kind of thing, and only one of those two is supposed to be deduplicated.</p><h3>The inversion: give the action its own type, and its own identity</h3><p>The actual pattern separates the two: a one-shot action isn’t a field on state, it’s its own object, UiEffect, attached through a dedicated slot:</p><pre>abstract class UiEffect extends Equatable {<br>  UiEffect() : _timestamp = DateTime.now().microsecondsSinceEpoch;<br>  final int _timestamp;<br>  <br>  @override<br>  List&lt;Object?&gt; get props =&gt; [_timestamp];<br>}</pre><p>All six effect types extend this. The hidden timestamp is the one implementation detail the pattern needs: it makes every instance unique, so flutter_bloc can never mistake &quot;the same action, fired twice&quot; for &quot;nothing changed.&quot; UiState wires that uniqueness into how a whole state compares:</p><pre>@override<br>bool operator ==(Object other) {<br>  if (identical(this, other)) return true;<br>  if (other is! UiState) return false;<br>  return super == other &amp;&amp; effect == other.effect;<br>}<br><br>@override<br>int get hashCode =&gt; Object.hash(super.hashCode, effect);</pre><p>effect stays out of props — what rebuild comparisons use — but is folded into == directly. A widget watching only the visible fields never rebuilds just because an action fired; flutter_bloc&#39;s dedup check, which uses ==, can no longer treat two different actions as the same state, however identical their content looks.</p><p>The last piece is what actually <em>runs</em> the action — one widget, EffectListener, watching for exactly this:</p><pre>listenWhen: (prev, curr) =&gt; curr.hasEffect &amp;&amp; prev.effect != curr.effect,</pre><p>and one registry, EffectRegistry, mapping each effect&#39;s runtime type to a handler — a handler for snackbars, a handler for navigation, registered once at app startup and shared by every feature:</p><pre>registerNavEffectHandlers(globalEffectRegistry, router: router);<br>registerSnackbarEffectHandlers(globalEffectRegistry);</pre><p>No feature writes its own “how do I show an error” logic — every BLoC reaches for the same six action types and trusts the same two handlers to carry them out.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iQWTus3qtxqhzlE48g4SKg.png" /><figcaption><em>Left: what each equality check compares once the action is its own type — content-only (red, the naive version) versus content-plus-identity (blue, what shipped) — and why keeping the effect out of props still matters for ordinary rebuilds. Right: the same two failed logins, traced through flutter_bloc’s own emit() check on both designs — one drops the second toast, one doesn’t.</em></figcaption></figure><h3>“Isn’t a whole registry a lot of ceremony for a toast?”</h3><p>Fair question — a registry and a global registration step is a lot of machinery next to ScaffoldMessenger.of(context).showSnackBar(...). It&#39;s a lot for <em>one</em> toast. It stops looking like a lot once a second feature needs the same toast, a third needs the same dialog, and a fourth needs to navigate somewhere and get a typed answer back. The alternative isn&#39;t &quot;no ceremony&quot; — it&#39;s the same ceremony, rewritten per screen, with its own small inconsistencies each time. Centralizing the six action types centralizes their handling too: one snackbar handler decides what a warning looks like, everywhere.</p><p>The follow-up objection targets the equality trick: doesn’t forcing every action to be “never equal to the last one” defeat the point of Equatable? No — props and == answer different questions on purpose. props asks &quot;did the screen change?&quot; == asks &quot;should this be treated as a new action?&quot; For a one-shot instruction the honest answer is always yes, because running it is the entire reason it was emitted. Nobody deduplicates function calls by comparing their arguments; an effect isn&#39;t data to render, it&#39;s closer to a call.</p><h3>The payoff: a navigation result, with no Future in sight</h3><p>Once an action is a real, uniquely-identified object instead of a call, it can carry things a plain function call couldn’t — like a typed callback. NavigatePushEffect carries an optional onResult, invoked after the pushed screen returns:</p><pre>NavigatePushEffect.withResult&lt;String&gt;(<br>  keyId: HomeRouteKeys.home.id,<br>  input: const HomeInput(),<br>  onResult: (result) =&gt; print(&#39;Navigated back from Home with result: $result&#39;),<br>);</pre><p>The handler pushes the route, awaits the Future the navigator returns, and calls onResult with whatever came back — all outside the BLoC, which never awaits anything inside an event handler. That only works because two pushes to the same route, with two different callbacks, are guaranteed to be treated as distinct actions rather than collapsed into one. Fixing &quot;an action must always run, never get deduplicated&quot; and solving &quot;how do I get a value back from a pushed screen without exposing a Future to my BLoC&quot; turned out to be the same problem.</p><h3>Three takeaways</h3><p><strong>Model a one-shot action as its own type, not a field on your state.</strong> Bolting “what should happen” onto “what the screen shows” feels natural — they live in the same object anyway — but only one of them should ever be silently deduplicated, and your framework can’t tell them apart unless you do.</p><p><strong>Centralize the handling, not just the modeling.</strong> Giving actions their own type only pays off if every feature dispatches through the same registry. The reuse — one snackbar handler, one navigation handler, for the whole app — is the actual point; the type system just makes it possible.</p><p><strong>An identity problem hides inside almost every “run this once” mechanism.</strong> Ours showed up as a hidden timestamp defeating an equality check; yours might take a different shape. Either way, if your framework has a “skip it if nothing changed” optimization sitting under a one-shot action, check what happens the second time that action looks exactly like the last one.</p><p>If you’ve modeled one-shot UI actions as data in a different framework, I’d like to hear what your registry looks like.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d4c35c28fb16" width="1" height="1" alt=""><hr><p><a href="https://levelup.gitconnected.com/one-pipe-for-every-side-effect-how-our-flutter-blocs-fire-toasts-dialogs-and-navigation-without-d4c35c28fb16">One Pipe for Every Side Effect: How Our Flutter BLoCs Fire Toasts, Dialogs, and Navigation Without…</a> was originally published in <a href="https://levelup.gitconnected.com/">Level Up Coding</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[One Pipe for Every Side Effect: How Our Flutter BLoCs Fire Toasts, Dialogs, and Navigation Without…]]></title>
            <link>https://medium.com/@muhammadrisky1401/one-pipe-for-every-side-effect-how-our-flutter-blocs-fire-toasts-dialogs-and-navigation-without-aa104d375c4b?source=rss-8cd4c1cce7e9------2</link>
            <guid isPermaLink="false">https://medium.com/p/aa104d375c4b</guid>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[flutter-app-development]]></category>
            <category><![CDATA[flutter-state-management]]></category>
            <category><![CDATA[mobile-development]]></category>
            <category><![CDATA[software-architecture]]></category>
            <dc:creator><![CDATA[Muhammad Rizky]]></dc:creator>
            <pubDate>Wed, 02 Sep 2026 01:36:29 GMT</pubDate>
            <atom:updated>2026-09-02T01:36:29.745Z</atom:updated>
            <content:encoded><![CDATA[<h3>One Pipe for Every Side Effect: How Our Flutter BLoCs Fire Toasts, Dialogs, and Navigation Without Touching BuildContext</h3><h4><em>In our shared Flutter platform, a BLoC never calls </em><em>Navigator.push or </em><em>ScaffoldMessenger.showSnackBar directly. Every one-shot UI action — a snackbar, a dialog, four different kinds of navigation — is instead emitted as plain data and carried out by one shared listener. Here&#39;s the side-effect pattern, the naive version of it that quietly eats a repeated error message, and the one trick that keeps it from happening.</em></h4><p>Six kinds of one-shot UI action exist in our shared Flutter platform: show a snackbar, show a dialog, and four flavors of navigation — go, push, replace, pop. Every one is handled by exactly one widget and one registry. Not a single BLoC calls Navigator.push, ScaffoldMessenger.of(context).showSnackBar, or anything else needing a BuildContext, directly. A BLoC emits a value describing what should happen, and something else — registered once, at startup — makes it happen.</p><p>That’s the whole idea: a “side effect” — show this, navigate there — is not a method call, it’s data, the same way the BLoC’s visible state is data. That sounds like a small distinction until you build it, because the moment a one-shot action lives <em>on</em> your state object, it inherits everything your state-management library does to states — including the parts you didn’t want.</p><h3>The plan that looks obviously right</h3><p>Say you’re modeling a failed sign-in. The BLoC already has a state object; the natural move is to give it a field for what went wrong:</p><pre>// The tempting first draft — an action, stored as inert data on state.<br>class AuthUnauthenticated extends AuthState {<br>  const AuthUnauthenticated({this.errorMessage});<br>  final String? errorMessage;<br>}</pre><p>A widget listens for errorMessage and shows a snackbar when it&#39;s non-null. It works the first time. Then picture a user typing the same wrong password twice in a row:</p><pre>// Same shape as the real sign-in<br>// handler, with the action modeled as a plain field instead of an effect.<br>try {<br>  final result = await _authRepository.signIn(email: event.email, password: event.password);<br>  emit(AuthAuthenticated(result));<br>} on Failure catch (failure) {<br>  emit(AuthUnauthenticated(errorMessage: failure.message));<br>}</pre><p>Two calls to emit(), two AuthUnauthenticated states, identical message both times. That should be harmless — except flutter_bloc&#39;s emit() compares the new state to the current one and does nothing if they&#39;re equal. Exactly the behavior you want when a BLoC re-emits an unchanged loading state. Exactly the behavior you don&#39;t want here: two states with the same errorMessage are, as far as Equatable is concerned, the same state, so the second emit() is silently swallowed. The user who fails twice in a row sees an error toast exactly once.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*TZerFXBbPKSu0pILnX8FFg.jpeg" /><figcaption><em>Login attempt #2, from the user’s side: no toast, no spinner, no anything. The action was real data on the state — which is exactly the problem.</em></figcaption></figure><p>The deeper issue isn’t the toast — it’s that “an action that must run” and “a value that describes the screen” got treated as the same kind of thing, and only one of those two is supposed to be deduplicated.</p><h3>The inversion: give the action its own type, and its own identity</h3><p>The actual pattern separates the two: a one-shot action isn’t a field on state, it’s its own object, UiEffect, attached through a dedicated slot:</p><pre>abstract class UiEffect extends Equatable {<br>  UiEffect() : _timestamp = DateTime.now().microsecondsSinceEpoch;<br><br>  final int _timestamp;<br>  <br>  @override<br>  List&lt;Object?&gt; get props =&gt; [_timestamp];<br>}</pre><p>All six effect types extend this. The hidden timestamp is the one implementation detail the pattern needs: it makes every instance unique, so flutter_bloc can never mistake &quot;the same action, fired twice&quot; for &quot;nothing changed.&quot; UiState wires that uniqueness into how a whole state compares:</p><pre>@override<br>bool operator ==(Object other) {<br>  if (identical(this, other)) return true;<br>  if (other is! UiState) return false;<br>  return super == other &amp;&amp; effect == other.effect;<br>}<br><br>@override<br>int get hashCode =&gt; Object.hash(super.hashCode, effect);</pre><p>effect stays out of props — what rebuild comparisons use — but is folded into == directly. A widget watching only the visible fields never rebuilds just because an action fired; flutter_bloc&#39;s dedup check, which uses ==, can no longer treat two different actions as the same state, however identical their content looks.</p><p>The last piece is what actually <em>runs</em> the action — one widget, EffectListener, watching for exactly this:</p><pre>listenWhen: (prev, curr) =&gt; curr.hasEffect &amp;&amp; prev.effect != curr.effect,</pre><p>and one registry, EffectRegistry, mapping each effect&#39;s runtime type to a handler — a handler for snackbars, a handler for navigation, registered once at app startup and shared by every feature:</p><pre>registerNavEffectHandlers(globalEffectRegistry, router: router);<br>registerSnackbarEffectHandlers(globalEffectRegistry);</pre><p>No feature writes its own “how do I show an error” logic — every BLoC reaches for the same six action types and trusts the same two handlers to carry them out.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iQWTus3qtxqhzlE48g4SKg.png" /><figcaption><em>Left: what each equality check compares once the action is its own type — content-only (red, the naive version) versus content-plus-identity (blue, what shipped) — and why keeping the effect out of props still matters for ordinary rebuilds. Right: the same two failed logins, traced through flutter_bloc’s own emit() check on both designs — one drops the second toast, one doesn’t.</em></figcaption></figure><h3>“Isn’t a whole registry a lot of ceremony for a toast?”</h3><p>Fair question — a registry and a global registration step is a lot of machinery next to ScaffoldMessenger.of(context).showSnackBar(...). It&#39;s a lot for <em>one</em> toast. It stops looking like a lot once a second feature needs the same toast, a third needs the same dialog, and a fourth needs to navigate somewhere and get a typed answer back. The alternative isn&#39;t &quot;no ceremony&quot; — it&#39;s the same ceremony, rewritten per screen, with its own small inconsistencies each time. Centralizing the six action types centralizes their handling too: one snackbar handler decides what a warning looks like, everywhere.</p><p>The follow-up objection targets the equality trick: doesn’t forcing every action to be “never equal to the last one” defeat the point of Equatable? No — props and == answer different questions on purpose. props asks &quot;did the screen change?&quot; == asks &quot;should this be treated as a new action?&quot; For a one-shot instruction the honest answer is always yes, because running it is the entire reason it was emitted. Nobody deduplicates function calls by comparing their arguments; an effect isn&#39;t data to render, it&#39;s closer to a call.</p><h3>The payoff: a navigation result, with no Future in sight</h3><p>Once an action is a real, uniquely-identified object instead of a call, it can carry things a plain function call couldn’t — like a typed callback. NavigatePushEffect carries an optional onResult, invoked after the pushed screen returns:</p><pre>NavigatePushEffect.withResult&lt;String&gt;(<br>  keyId: HomeRouteKeys.home.id,<br>  input: const HomeInput(),<br>  onResult: (result) =&gt; print(&#39;Navigated back from Home with result: $result&#39;),<br>);</pre><p>The handler pushes the route, awaits the Future the navigator returns, and calls onResult with whatever came back — all outside the BLoC, which never awaits anything inside an event handler. That only works because two pushes to the same route, with two different callbacks, are guaranteed to be treated as distinct actions rather than collapsed into one. Fixing &quot;an action must always run, never get deduplicated&quot; and solving &quot;how do I get a value back from a pushed screen without exposing a Future to my BLoC&quot; turned out to be the same problem.</p><h3>Three takeaways</h3><p><strong>Model a one-shot action as its own type, not a field on your state.</strong> Bolting “what should happen” onto “what the screen shows” feels natural — they live in the same object anyway — but only one of them should ever be silently deduplicated, and your framework can’t tell them apart unless you do.</p><p><strong>Centralize the handling, not just the modeling.</strong> Giving actions their own type only pays off if every feature dispatches through the same registry. The reuse — one snackbar handler, one navigation handler, for the whole app — is the actual point; the type system just makes it possible.</p><p><strong>An identity problem hides inside almost every “run this once” mechanism.</strong> Ours showed up as a hidden timestamp defeating an equality check; yours might take a different shape. Either way, if your framework has a “skip it if nothing changed” optimization sitting under a one-shot action, check what happens the second time that action looks exactly like the last one.</p><p>If you’ve modeled one-shot UI actions as data in a different framework, I’d like to hear what your registry looks like.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=aa104d375c4b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How Two Routing Packages Share One App Without a Single if]]></title>
            <link>https://medium.com/@muhammadrisky1401/how-two-routing-packages-share-one-app-without-a-single-if-c9b3816e2e03?source=rss-8cd4c1cce7e9------2</link>
            <guid isPermaLink="false">https://medium.com/p/c9b3816e2e03</guid>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[refactoring]]></category>
            <category><![CDATA[software-architecture]]></category>
            <dc:creator><![CDATA[Muhammad Rizky]]></dc:creator>
            <pubDate>Tue, 01 Sep 2026 06:41:42 GMT</pubDate>
            <atom:updated>2026-09-01T06:41:42.051Z</atom:updated>
            <content:encoded><![CDATA[<h4><em>Mid-migration our Flutter app runs GetX and go_router side by side. Here’s one navigation traced end to end — and why the BLoC that triggers it never has to ask which router will answer.</em></h4><p>Here’s the constraint that shaped everything below: for the entire length of our migration, the app has to run <strong>two navigation systems at the same time</strong>.</p><p>We’re moving a production banking app off GetX onto BLoC and go_router, feature by feature, without a rewrite. At any moment some screens have been migrated and live in the new router, and the rest still live in the old GetX navigator. Both are in the same binary. Both work. Which world a given screen belongs to changes every sprint — that’s the whole point of migrating incrementally.</p><p>That creates an awkward question for any BLoC that navigates. Say a flow finishes and needs to send the user onward. If the BLoC calls a router directly, it has to know <em>which</em> router owns the destination today. Multiply by every navigation in the app, and every screen that crosses over means editing business logic somewhere else — exactly the unbounded blast radius a strangler-fig migration exists to avoid.</p><p>Our answer turned out not to need a new abstraction at all. The BLoC already had a place where “what happens after this action succeeds” lives: a small getter next to the event handler, returning a one-shot effect. All the migration needed was for that getter to sometimes return one type of effect, and sometimes another.</p><p><strong>The map:</strong> a BLoC finishes an action and picks an effect getter → the effect goes out attached to the state → a listener forwards it → a registry dispatches on its type → one of two routers answers → a screen builds.</p><h3>Step 0: what’s already wired before anything navigates</h3><p>Two things happen at startup, and neither is optional.</p><p>First, every migrated feature declares its screens and bundles them into a module. A screen is a name bound to the data it needs, plus the function that builds it:</p><pre>abstract final class AuthRouteKeys {<br>  static const landing = RouteKey&lt;EmptyInput&gt;(&#39;auth.landing&#39;);<br>}<br><br>final class AuthRouteModule extends FeatureRouteModule {<br>  const AuthRouteModule();<br>  @override<br>  List&lt;RouteNode&gt; get routes =&gt; [<br>    RouteNode.typed&lt;EmptyInput&gt;(<br>      key: AuthRouteKeys.landing,<br>      defaultInput: EmptyInput.new,<br>      builder: (context, input) =&gt; const AuthLandingPage(),<br>    ),<br>  ];<br>}</pre><p>FeatureRouteModule is the contract every feature implements — one routes getter, nothing else required. Every feature&#39;s module gets listed in one place, and that list is the <em>only</em> thing the app-level registry ever sees:</p><pre>static final _modules = &lt;FeatureRouteModule&gt;[<br>  const SplashRouteModule(),<br>  const AuthRouteModule(),<br>  const OtpRouteModule(),<br>  const PinSetupRouteModule(),<br>  // ...six more<br>];<br><br>static final _registry = RouteRegistry.fromModules(_modules);<br>static GoRouter buildAppRouter() =&gt; GoRouter(<br>  routes: _registry.registeredNodes.map((n) =&gt; n.toGoRoute()).toList(),<br>);</pre><p>RouteRegistry.fromModules walks every module&#39;s routes, collects them into one map keyed by route name, and asserts in debug builds that no two features claimed the same name. buildAppRouter then turns every entry into a real GoRoute via toGoRoute() — hold onto that method name, it comes back in Step 4.</p><p>Adding a feature to the migration means adding one line to _modules. Nothing else on this list changes.</p><p>Second — and this is the part that matters for the two-router problem — the app registers what navigation <em>means</em>:</p><pre>void registerEffectHandlers({required GoRouter router}) {<br>  registerNavEffectHandlers(globalEffectRegistry, router: router);<br>  // TODO: Remove once all destinations are migrated to the new router.<br>  registerGetXNavEffectHandlers(globalEffectRegistry);<br>}</pre><p>Until that runs, the app physically cannot navigate. The thing that gives navigation meaning starts out empty.</p><h3>Step 1: the BLoC picks an effect getter — no destination type in sight</h3><p>Here’s the whole use case. A BLoC finishes handling an event and needs to send the user somewhere. It reaches for a small getter defined right next to it, and that getter’s return type <em>is</em> the routing decision:</p><pre>extension AuthSideEffect on AuthBloc {<br>  // &#39;auth.landing&#39; has been migrated — goes through the new router.<br>  NavigateGoEffect get _effectGoToLanding =&gt; NavigateGoEffect(<br>    keyId: AuthRouteKeys.landing.id,<br>    input: const EmptyInput(),<br>  );<br>  <br>  // MAIN_PAGE hasn&#39;t been touched yet - still legacy GetX.<br>  GetXNavigateEffect get _effectGoToMain =&gt; GetXNavigateEffect(<br>    AppRoute.MAIN_PAGE,<br>  );<br>}</pre><p>There’s no shared “destination” type, no if (isMigrated). There are just two effect <em>types</em> — NavigateGoEffect and GetXNavigateEffect — and each getter is hardcoded to whichever one matches where its target screen currently lives:</p><pre>Future&lt;void&gt; _onSomeActionSucceeded(..., Emitter&lt;AuthState&gt; emit) async {<br>  emit(AuthDone(effect: _effectGoToLanding));<br>  // or _effectGoToMain, depending on the flow<br>}</pre><p><strong>That’s the entire routing decision, and it lives at the call site.</strong> No sealed type, no switch, no lookup. Migrating a screen means changing one getter’s body from GetXNavigateEffect(...) to NavigateGoEffect(...) — a one-line edit, in the file that already owned the decision.</p><h3>Step 2: a listener forwards, a registry dispatches</h3><p>The screen is wrapped in an EffectListener, which watches the state stream and hands off any <em>new</em> effect without inspecting it:</p><pre>listenWhen: (prev, curr) =&gt; curr.hasEffect &amp;&amp; prev.effect != curr.effect,<br>listener: (context, state) =&gt; (registry ?? globalEffectRegistry).handle(context, state.effect!),</pre><p>That listenWhen matters: effects are one-shot, so they must fire once and not again on the next unrelated rebuild. Each effect instance is unique, which makes &quot;the effect changed&quot; a reliable signal.</p><p>The registry is a plain map from effect <em>type</em> to a handler:</p><pre>void handle(BuildContext context, UiEffect effect) {<br>  final handler = _handlers[effect.runtimeType];<br>  if (handler == null) throw UnregisteredEffectError(effect);<br>  handler(context, effect);<br>}</pre><p>Note what’s missing from both: any concept of navigation. The listener forwards. The registry dispatches on type. Neither knows a router exists, and neither knows the BLoC ever made a choice.</p><h3>Step 3: the handler for that type answers</h3><p>Here’s what Step 0 registered — two files, each knowing exactly one router:</p><pre>// nav_effect_handler.dart — knows go_router<br>registry.register&lt;NavigateGoEffect&gt;((context, effect) {<br>  router.go(&#39;/${effect.keyId}&#39;, extra: effect.input);<br>});<br><br>// getx_nav_effect_handler.dart - knows the legacy navigator<br>registry.register&lt;GetXNavigateEffect&gt;((context, effect) {<br>  Get.offAllNamed(effect.route, arguments: effect.arguments);<br>});</pre><p>Neither contains a branch. They can’t collide either — the registry throws on duplicate registration, and these are two different type keys in the same map. Which one runs was decided the moment the BLoC picked a getter in Step 1; by the time the effect reaches here, its type has already made the choice.</p><h3>Step 4: the screen builds</h3><p>If the new router answered, go_router matches /auth.landing against the routes built back in Step 0. Each of those routes came from toGoRoute() — and inside that method sits a pageBuilder, defined once at startup but only <em>executed</em> now, when this specific path is matched:</p><pre>// Inside RouteNode.toGoRoute() — built in Step 0, runs now in Step 4.<br>pageBuilder: (context, state) {<br>  final RouteInput input;<br>  final extra = state.extra;               // whatever Step 3 passed as `extra: effect.input`<br>  if (extra is RouteInput) {<br>    input = extra;<br>  } else if (defaultInput != null) {<br>    input = defaultInput!;                 // deep link: no extra was ever passed<br>  } else {<br>    throw StateError(&#39;Route &quot;$keyId&quot; received no RouteInput ...&#39;);<br>  }<br>  return buildWidget(context, input);      // the builder from Step 0&#39;s RouteNode.typed<br>}</pre><p>state.extra is exactly the input object Step 3&#39;s handler passed in as router.go(..., extra: effect.input) — this is where it lands, and where it gets cast back from Object? to a real RouteInput. The defaultInput branch exists for a case this walkthrough doesn&#39;t otherwise hit: someone opens /auth.landing from a deep link, with no effect and no extra ever constructed. AuthRouteModule supplied defaultInput: EmptyInput.new back in Step 0 for exactly that case — without it, a deep link into this route would throw instead of opening.</p><p>If the legacy navigator answered instead, Get.offAllNamed clears the old stack and pushes the old page — no pageBuilder, no RouteInput, none of the above. Same BLoC, same registry, same mechanism — different world, decided back in Step 1 by which effect type got constructed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*otM_I7ac_OtmyFo4TnK0Fw.png" /><figcaption><em>Left: where each piece lives, and which layer is allowed to see which. Right: the same navigation traced hop by hop, with the two routers meeting only at the final step.</em></figcaption></figure><h3>So why does one getter’s return type carry so much weight?</h3><p>The instinct when you first hit this problem is to reach for an abstraction: something with an explicit “decide which router” step, looked up at the moment of navigating. We started down that road and backed out of it, because the BLoC already had the only place the decision needed to live.</p><p>A BLoC’s side-effect getter is, by construction, specific to one exact outcome — “the login succeeded, go to landing.” It was never generic over <em>where</em> landing lives. So instead of building a layer to make that lookup dynamic, we just let the getter’s hardcoded return type be the answer. The type system already distinguishes NavigateGoEffect from GetXNavigateEffect; that distinction was sitting there for free.</p><p>The payoff shows up in the dependency lists. Our BLoC package depends on flutter_bloc and a logging package. Our navigation package depends on Flutter. Neither has ever imported go_router or GetX, which means neither had to change when the migration started, and neither will change when it ends.</p><p>And the endgame is unusually clean. Migrating a screen means editing one getter, in one file, to construct a different effect type. When the last GetXNavigateEffect-returning getter is rewritten, that effect type has no emitters left anywhere in the codebase, its handler registration comes out of registerEffectHandlers, and the whole handler file gets deleted. The TODO above it is already waiting for that day.</p><p>It costs something, and it’s worth naming. The destination inside each effect — keyId or route — is just a string. Misspell one and nothing complains until it fails to resolve at runtime. The type only comes back at the very end, in Step 4&#39;s cast — which throws loudly and names the route, but throws all the same.</p><h3>Takeaways</h3><ol><li><strong>A hardcoded choice is not the same as a missing one.</strong> Each getter always returns the same effect type — that’s not a gap to generalize away, it’s the routing decision already made, sitting in the type system.</li><li><strong>Dispatching on type beats branching on a condition.</strong> Two routers could have meant an if in every navigation. Two effect types instead meant two handlers that never reference each other — and a deletion, rather than an edit, when one becomes obsolete.</li></ol><p>If you’ve run a migration where two competing frameworks had to coexist in one binary, I’d be curious where you put the seam between them.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c9b3816e2e03" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[One BLoC, Many Flows: How We Stopped Building the Third Login-Adjacent Screen by Copy-Paste]]></title>
            <link>https://medium.com/@muhammadrisky1401/one-bloc-many-flows-how-we-stopped-building-the-third-login-adjacent-screen-by-copy-paste-969d1ec5369c?source=rss-8cd4c1cce7e9------2</link>
            <guid isPermaLink="false">https://medium.com/p/969d1ec5369c</guid>
            <category><![CDATA[software-architecture]]></category>
            <category><![CDATA[mobile-development]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[refactoring]]></category>
            <dc:creator><![CDATA[Muhammad Rizky]]></dc:creator>
            <pubDate>Fri, 28 Aug 2026 02:19:44 GMT</pubDate>
            <atom:updated>2026-08-28T02:19:44.755Z</atom:updated>
            <content:encoded><![CDATA[<h4><em>A code audit found three separate implementations of the same six-digit OTP timer in one app — each with a different bug. The fix wasn’t a style guide. It was borrowing an idea from restaurant kitchens: recipes don’t know how to boil an egg, and the eggs station doesn’t care which dish ordered it.</em></h4><p>Three. That’s how many separate implementations of the same wall-clock OTP resend timer a code audit found sitting inside one app’s login, registration, and device-activation flows — six-digit code, “resend in 30s,” the works, written from scratch three times. They didn’t even agree with each other: one discarded the actual resend interval the server returned and used a hardcoded one instead. Another leaked its timer when the screen closed. Two disagreed on the interval math — one did ~/1000, the other ~/60000*60, and if you&#39;re squinting at that trying to spot the bug, that&#39;s exactly the point.</p><p>Nobody sat down and decided to write OTP verification three times. Each one was the second or third “almost the same as login” flow, and copying the first one that already worked was the obviously correct call every time it was made. Here’s the analogy that ended up fixing it: think of a kitchen where every recipe card has “boil an egg for exactly 6 minutes” hand-written into its own instructions, instead of just saying “send an order to the eggs station.” Three recipe cards, three hand-copied egg instructions, three slightly different ideas of how long six minutes is.</p><h3>The plan that felt obviously right</h3><p>Picture being the cook who has to write the third recipe, and the first one already works. Login’s OTP screen is a LoginController that owns the whole dish: step order, timer, interval math, the verify call, the on-screen copy — all handwritten into one recipe card, because the dish needed to ship.</p><p>Now you need “boil an egg” for a completely different dish, and there’s no station to send an order to — only someone else’s recipe card with the egg instructions buried halfway down it, tangled up with that dish’s own plating order. Untangling just the egg part means surgery on a card that isn’t yours. Photocopying the whole card and crossing out what doesn’t apply is less work, today, than that surgery. So that’s what happens. Three times.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2F3sT2ENJJOi3hRVRFA0%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2Fv1.Y2lkPTc5MGI3NjExcWpiZXF0YXNiNHo0Mml5a2FnM2lnMXBsZWx4d3B3aXJreGc5anp3bCZlcD12MV9naWZzX3NlYXJjaCZjdD1n%2F3sT2ENJJOi3hRVRFA0%2Fgiphy.gif&amp;image=https%3A%2F%2Fmedia3.giphy.com%2Fmedia%2Fv1.Y2lkPTc5MGI3NjExd3doNnlhNGFjc3AxaXlvemE4bGVsMzRodGQyMHN1azl2czRyMGVlZyZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw%2F3sT2ENJJOi3hRVRFA0%2Fgiphy_s.gif&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="435" frameborder="0" scrolling="no"><a href="https://medium.com/media/86859b3b6da0a7475c287e0431b2d56d/href">https://medium.com/media/86859b3b6da0a7475c287e0431b2d56d/href</a></iframe><p>The inversion: a menu and a station are not the same job</p><p>The fix was to stop letting one recipe card own both “what order do the courses come out in” and “how exactly do you boil an egg,” and to split every flow into two components forbidden from doing each other’s job.</p><p>A <strong>coordinator</strong> is the order ticket for one specific dish: it owns the step order and whatever context builds up along the way — LoginCoordinator, DeviceActivationBloc. It doesn&#39;t know how OTP verification works, the same way a ticket doesn&#39;t know how to boil anything; it just knows <em>when</em> eggs are needed relative to everything else.</p><p>A <strong>capability</strong> is the station: a self-contained specialist with no idea which dish is calling it — OtpBloc, ConsentBloc, PinSetupBloc. It doesn&#39;t ask which table ordered it or what&#39;s served alongside it. It takes a ticket describing exactly what&#39;s needed, and hands back a finished result. In code, that ticket is a plain typed contract: an Input going in, a Result coming out.</p><pre>class OtpInput {<br>  final String target;                 // what to verify against<br>  final Duration resendInterval;       // policy, decided by the caller<br>  final Future&lt;OtpVerifyResult&gt; Function(String code) verify;<br>}</pre><p>A coordinator hands the capability an Input describing everything it needs for <em>this</em> order, and gets back a typed result — nothing else crosses the counter:</p><pre>final result = await pushCapability&lt;OtpBloc, OtpInput, OtpResult&gt;(<br>  OtpInput(<br>    target: phoneNumber,<br>    resendInterval: policy.otpResendInterval,<br>    verify: authRepository.verifyOtp,<br>  ),<br>);<br><br>if (result.isSuccess) coordinator.advanceToNextStep();</pre><p>OtpBloc never hardcodes a resend interval and never knows which dish ordered it. Every coordinator that needs OTP verification sends an order to the same station, describing its own policy through the ticket it writes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xqERJob3Hhh381RaOMi3fA.png" /><figcaption><em>Left: the old LoginController with step order, timer math, and the verify call handwritten into one recipe card, versus a coordinator sending orders to three independent stations. Right: three different order tickets, each with its own timing, sent to the same OtpBloc station.</em></figcaption></figure><h3>“Isn’t this just indirection for indirection’s sake?”</h3><p>It’s a fair question — writing a ticket instead of just boiling the eggs yourself is, in the moment, one extra step. The payoff is in what that step buys: the coordinator never touches timer math, and the station never touches which dish it’s serving. If that counter ever gets fuzzy — if OtpBloc starts reading something off a shared flow object instead of its own Input ticket — the station has quietly wandered into the dining room and started taking orders directly, which is exactly the fused mess this split was meant to prevent. The indirection only pays off if the counter stays solid both ways.</p><h3>The trap on the other side: templating the menu itself</h3><p>The obvious next move, once the stations are shared, is to make the order tickets shared too — a fill-in-the-blanks menu template where a new dish means filling out a form instead of writing a ticket by hand. This was tried on paper and rejected. A templated menu trades an explicit, readable order — “eggs, then sauce, then plate” — for a config file that’s much harder to read when one order stalls between courses for a reason nobody anticipated. A head chef who can point at exactly where an order stalled beats a clever template. Reuse comes from sharing stations — not from making the ticket-writing itself generic.</p><h3>The payoff nobody was hunting for</h3><p>The bug-fixing story ran in the direction you’d hope. Once the three hand-copied egg instructions collapsed into one OtpBloc station, the discarded resend interval, the leaked timer, and the disagreeing interval math all disappeared in the same change — not because anyone went looking for them, but because fixing the one remaining station was the only station left to fix. Consolidation surfaced bugs as a side effect of removing duplication, which is a far cheaper way to find them than a dedicated bug hunt.</p><p>The other payoff showed up in the kitchen’s shape. The pantry that used to hold every ingredient for every dish — one repository interface that had grown to more than 40 methods spanning login, PIN, consent, cards, and crypto — shrank to three focused stations once PIN, crypto, and consent each got their own counter. Writing the <em>next</em> dish stopped being “whose recipe card do I photocopy” and became “which stations do I already have, and in what order do I send them tickets.”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/976/1*qIQtzCrP8u3GI780eN2qug.png" /><figcaption><em>The fast option and the right option, finally the same option.</em></figcaption></figure><h3>Three takeaways</h3><ol><li><strong>Duplication is a decomposition problem wearing a discipline costume.</strong> Copying feels like laziness from the outside, but from inside the third recipe it’s the fastest available option, because the instructions you need are handwritten into a card you don’t own. Fix the handwriting, not the copying habit.</li><li><strong>Give the shared station a ticket, not just a name.</strong> Extracting “the egg part” into its own class doesn’t help if it still reaches into whatever context object happens to be sitting on the counter. The typed Input → Result boundary is what actually stops a station from quietly growing back into a second order ticket.</li><li><strong>Keep the menu boring on purpose.</strong> The instinct to make the <em>ordering</em> generic once the <em>stations</em> are shared is strong — resist it in domains where a reviewable, readable sequence matters more than an elegant template. Share the stations; leave the ticket-writing explicit.</li></ol><p>If you’ve drawn this same line — shared stations, explicit tickets — in a different stack, I’d like to hear what you called the two halves.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=969d1ec5369c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Boot the New Architecture First: The Backwards Move That Made Our Migration Work]]></title>
            <link>https://medium.com/@muhammadrisky1401/boot-the-new-architecture-first-the-backwards-move-that-made-our-migration-work-c3073d009df1?source=rss-8cd4c1cce7e9------2</link>
            <guid isPermaLink="false">https://medium.com/p/c3073d009df1</guid>
            <category><![CDATA[software-architecture]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[refactoring]]></category>
            <category><![CDATA[mobile-development]]></category>
            <dc:creator><![CDATA[Muhammad Rizky]]></dc:creator>
            <pubDate>Thu, 27 Aug 2026 04:31:44 GMT</pubDate>
            <atom:updated>2026-08-27T04:31:44.062Z</atom:updated>
            <content:encoded><![CDATA[<h4>Our production Flutter banking app starts up inside the new navigation system on day one, even though almost every screen is still the old one. Here’s why the new code should be the host, not the guest.</h4><p>Two months into moving a production Flutter banking app off GetX, the old navigator has learned exactly two new routes. Not two per migrated feature. Two in total, for the whole migration.</p><p>That number comes from one decision that felt wrong when we made it. <strong>The app starts up inside the new architecture from day one</strong>, before we had migrated almost anything. The new code takes over at launch, and then sends users straight back out to old screens.</p><p>If you know the strangler fig pattern, that sounds backwards. The old system is supposed to stay in charge while the new one grows around it. Here’s why we flipped it, and why I’d do it again on day one of the next migration.</p><h3>The front desk that doesn’t exist</h3><p>Picture the classic strangler fig as a building with a front desk. Every visitor checks in there. The receptionist decides where to send them: the old wing, or the new wing that’s slowly being built. The old building stays in charge, and the desk quietly sends more and more people to the new side.</p><p>That works on the web because the front desk is already there. It’s your load balancer or your reverse proxy, and someone else already runs it.</p><p>A mobile app has no front desk. There’s one building and one door, and it opens straight into the old wing.</p><p>We didn’t notice that at first, so our plan was the obvious translation. Keep the old app in charge. When we migrate Login, add an old route /auth-v2 that opens a small shell — a FeatureShellPage — holding its own router for the new login screens. When we migrate one-time codes, add /otp-v2 with GoRouter #2 inside its own shell. When we migrate consent, /consent-v2 with GoRouter #3. One shell per feature, one router per shell.</p><p>In building terms: instead of one front desk, we were giving every renovated room its own receptionist.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-zEJi4yaylT2COCHeUbCDg.png" /><figcaption><em>Left: three shells, three routers, none of them able to see each other. Right: what actually happens when Auth needs to hand off to OTP.</em></figcaption></figure><p>The right half of that picture is the part that convinced us to stop. Auth’s shell can’t navigate to OTP’s shell directly — they’re two separate GoRouter instances with no path between them. So the flow has to exit all the way back out to the legacy stack, look up /otp-v2 in the old route table, and re-enter through a brand new shell. That round trip isn&#39;t free:</p><ul><li><strong>Auth’s in-memory state doesn’t travel with it.</strong> OTP boots cold, as if the user had just opened the app.</li><li><strong>The back button now has to unwind two shells, not one.</strong> Every extra hop is another place for the navigation stack to end up somewhere wrong.</li><li><strong>This happens once per feature, slightly differently each time.</strong> Ten migrated features would have meant ten near-identical bridges, each one a little different from the last.</li></ul><p>And underneath all of it, the legacy route table keeps growing — /auth-v2, /otp-v2, /consent-v2, one new entry per feature — which quietly breaks the rule that legacy code stays frozen.</p><p>Here’s the part that took us days to see. We thought starting up in the new world would break the pattern. It doesn’t. The pattern’s real promise is simple: <strong>old code keeps running, untouched, until its replacement is proven.</strong> That’s the safety part, and we weren’t touching it. “The old system owns the front door” was never the promise. It was just a convenience of web setups, where the front desk comes for free.</p><p>In a single app, you have to build the front desk yourself. Where you put it is your choice.</p><h3>Putting the desk at the door</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6KBH4G8Yaw_GeNCSH1sw3g.png" /><figcaption><em>Left: one shell, one shared router, ten feature modules registered into it. Right: what happens at launch — the bridge sets up the new world once, then every screen after that navigates inside the same router.</em></figcaption></figure><p>So we flipped who’s in charge. The old navigator learns two routes and never learns another:</p><ol><li>/initialize-v2 — starts the new runtime, then leaves.</li><li>/v2-shell — one page holding one router that every migrated feature plugs into.</li></ol><p>The app’s initialRoute points at the first one. The bridge is boring on purpose:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0dc9b19f37f1b528a8bc7e6e63614057/href">https://medium.com/media/0dc9b19f37f1b528a8bc7e6e63614057/href</a></iframe><p>After that, a small startup step works out where the user actually belongs and returns one of two labelled answers: LegacyGetXDestination(&#39;/some-old-route&#39;) or GoRouterDestination(routeKey).</p><p>That’s the whole idea. The new architecture is the front desk. The old wing is just one of two places it can send you. Old screens still run the exact code they ran yesterday — they’re simply reached through a desk that knows they’re temporary.</p><p>And migrating a screen becomes one line: change the label from “old wing” to “new wing”. No new route in the old table. No new router. No new back-button code — auth, OTP, consent, and seven other features all navigate inside the same GoRouter, so a hand-off between any two of them is just a normal route change, not a round trip through legacy.</p><p>One thing that isn’t free: each feature still needs its own scope. A route builder opens a small ScopeWidget for its own dependencies, and that scope is torn down the moment the user leaves those routes — so &quot;one router&quot; doesn&#39;t mean &quot;one giant bag of shared state.&quot; It means one place where navigation decisions get made.</p><h3>“Isn’t it risky to start up through unfinished code?”</h3><p>That was the first objection in review, and it’s a fair one. Three answers.</p><p><strong>You hit the hard problems in week one.</strong> Starting the new container, loading the router config, the theme, the observers: these either work together or they don’t. In week one the bridge is thirty lines and nothing depends on it. Finding out in month nine that your new runtime can’t start before the first frame is a much worse week.</p><p><strong>If it breaks, it breaks in one place.</strong> The bridge does four things and leaves. A failure shows up on the splash screen, the same way, on every single launch. That’s the easiest kind of bug there is.</p><p><strong>Undo is one line.</strong> Point initialRoute back at the old entry screen and the new world is never built at all. A config change, not an emergency release.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KN_AyzR_GmncYB8tpXg7PQ.jpeg" /><figcaption><em>“So on day one, all of your users start up through code that serves zero migrated screens?” Yes. And that’s the cheap time to ask.</em></figcaption></figure><h3>What you get at the end</h3><p>Here’s the bonus we didn’t plan for: this setup writes the ending for you.</p><p>Every migration deletes one “old wing” label and adds a “new wing” one. Progress stops being a feeling and becomes something you can count. And when the last old label is gone, the old navigator has nothing left to serve except the two bridge routes. Replacing it at the root turns from a scary milestone into a cleanup commit.</p><p>Starting up in the new architecture doesn’t just begin the migration. It tells you what <em>finished</em> looks like, as a number that counts down to zero.</p><p><strong>Three things to take away:</strong></p><ol><li><strong>If there’s no front desk, build one, and build it first.</strong> In an app, that’s the startup path. Own it before you migrate a single feature.</li><li><strong>One desk, not one per room.</strong> One shared router beats N small ones every time.</li><li><strong>Make the old code a destination, not the owner.</strong> Then each migration is a one-line change, and your endgame is arithmetic.</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c3073d009df1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Migrating to Flutter Without a Rewrite, Part 3: The Bridge, and Living With It]]></title>
            <link>https://medium.com/@muhammadrisky1401/migrating-to-flutter-without-a-rewrite-part-3-the-bridge-and-living-with-it-18f4d100fc9d?source=rss-8cd4c1cce7e9------2</link>
            <guid isPermaLink="false">https://medium.com/p/18f4d100fc9d</guid>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[software-architecture]]></category>
            <dc:creator><![CDATA[Muhammad Rizky]]></dc:creator>
            <pubDate>Fri, 24 Jul 2026 13:54:46 GMT</pubDate>
            <atom:updated>2026-07-24T13:55:19.589Z</atom:updated>
            <content:encoded><![CDATA[<h4><em>What actually crosses the native↔Flutter boundary — sessions, secrets, a fresh engine per tap — how we test and ship it without a monthly game of production roulette, and the honest </em><em>delay(1500) we&#39;re still not proud of.</em></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FAqU9cIKLZKLeKEoqFjIJg.png" /></figure><p><a href="https://medium.com/@muhammadrisky1401/how-were-migrating-a-1m-install-finance-app-from-native-to-flutter-without-a-rewrite-aaef2c1295d1?sharedUserId=muhammadrisky1401">Parts 1</a> and <a href="https://medium.com/@muhammadrisky1401/migrating-to-flutter-without-a-rewrite-part-2-building-a-module-thats-built-to-disappear-55f0fdc4eeff?sharedUserId=muhammadrisky1401">2</a> built the skeleton: <em>why</em> we migrated incrementally, and the shape of the module that made it possible — one gateway, shipped like an SDK, built to eventually become the app. But a gateway and a channel contract are just plumbing until something real moves through them.</p><p>This part is about what moves. A user’s live, regulated session crossing the boundary without a second login. A Flutter engine spun up mid-tap and destroyed when the flow ends. Secrets that must never touch the Dart bundle. And the parts we got wrong — including a hard-coded delay(1500) that has outlived every sprint in which we swore we&#39;d remove it.</p><p>Then the unglamorous half nobody writes about: how you test and roll out a hybrid app every month without regressions, and what two years of this actually bought us.</p><h3>The handoff: a session that survives the border</h3><p>The single hardest requirement wasn’t technical elegance. It was this: <strong>a user mid-loan must never be asked to log in again because a screen happened to switch frameworks.</strong> In a regulated finance app, the session isn’t just a convenience token — it’s tied to identity verification, device binding, and an audit trail. It cannot be dropped, duplicated, or diverged.</p><p>So the session crosses the bridge in both directions, and the direction depends on who owns it in that moment.</p><p><strong>Native → Flutter, before anything renders.</strong> When native launches a Flutter flow, it serializes its entire runtime config — base URLs, API keys, device identity, environment, and the current session material — into a single channel call, <em>before</em> it tells Flutter to start. Flutter stores it and reads from it synchronously for the rest of the flow.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/cc626e1cd0fd44494796f4880e47adc7/href">https://medium.com/media/cc626e1cd0fd44494796f4880e47adc7/href</a></iframe><p>On the Flutter side, that payload lands on one handler and gets parsed into one long-lived config object that the rest of app/ reads from for the life of that engine — nothing downstream ever touches the channel again to get a base URL or a key.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/edd37a6bf0886e5ddfe6b6d25d9fa77b/href">https://medium.com/media/edd37a6bf0886e5ddfe6b6d25d9fa77b/href</a></iframe><p>Two things about this are deliberate and worth stealing:</p><ul><li><strong>No secrets live in the Dart bundle.</strong> Keys, tokens, and device identity are delivered at runtime by the trusted native layer. The AAR is inert on its own — decompiling it yields no credentials. For a regulator, “where do secrets come from?” has one answer: native, over the channel, per session.</li><li><strong>One binary runs every environment.</strong> Dev, staging, production — the artifact is identical; environment <em>is</em> config, and config arrives over the channel. That’s also what makes the standalone debug mode (below) possible.</li></ul><p><strong>Flutter → native, when a flow completes.</strong> When a login, registration, or PIN validation finishes inside Flutter, the result travels back the same way — customer ID, tokens and expiries, phone, PIN — and native persists it into the session store it already owns. This is the seam from Part 2 (closeLogin and friends): embedded, it&#39;s a channel call; in the eventual full app, it&#39;s a local SessionManager.saveCredential. Same destination, different owner, zero divergence — and, critically, no second login screen.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8f6fc6ea2c561f59be5e14cb2b96876e/href">https://medium.com/media/8f6fc6ea2c561f59be5e14cb2b96876e/href</a></iframe><p>The compliance framing that made this defensible: the session material that crosses the bridge is encrypted at rest on both sides, the keys are delivered by native rather than baked into Dart, and there is exactly one code path for the crossing — which is exactly what an auditor wants to see. The genuinely sensitive native pieces — biometric and liveness checks, secure storage, device binding, the payment SDKs — never moved to Dart at all; they stay native, each reachable as one more handler on the same channel, so the code the regulator already reviewed keeps doing its job while Flutter just calls it and waits for a result.</p><h3>The engine lifecycle: fresh every time, gone when you leave</h3><p>Add-to-app gives you a choice about engines, and most tutorials pick the wrong one for a migration. You can keep one long-lived FlutterEngine warm for the whole app, or you can create engines on demand. We create one <strong>fresh engine per flow, from a shared</strong><strong>FlutterEngineGroup, and destroy it when the flow exits</strong> (shouldDestroyEngineWithHost = true).</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b669f258023420efd54041772432da4d/href">https://medium.com/media/b669f258023420efd54041772432da4d/href</a></iframe><p>On the Dart side, that custom entry point is what “clean Dart VM” actually means in code: it’s the function that runs on every fresh engine, and everything it touches — the handler list, the channel listener — is rebuilt from nothing each time.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/415ec03f973aa8711746a7098a9b8df9/href">https://medium.com/media/415ec03f973aa8711746a7098a9b8df9/href</a></iframe><p>Why the more expensive-sounding option:</p><ul><li><strong>State isolation for free.</strong> Every entry into a migrated flow starts from a clean Dart VM. There is no stale provider, no leftover navigation stack, no “why is this screen showing yesterday’s data?” For a money app, that determinism is worth paying for.</li><li><strong>So why </strong><strong>FlutterEngineGroup at all, if we throw engines away?</strong> Fair question — and the honest answer is narrower than most articles imply. Per Flutter&#39;s docs, the group&#39;s resource sharing (GPU context, font metrics, isolate group snapshot; ~180 kB per extra instance) only kicks in <em>while at least one engine from the group is alive</em>. The first engine — or the next one created after all others are destroyed — pays a normal cold start, identical to a plain FlutterEngine. So for a single flow entered and fully exited, the group buys nothing. What it buys is the case where instances <em>overlap</em>: a hybrid native → Flutter → native → Flutter stack where an engine is still alive, and the separate engines our standalone sub-products use, which can run at the same time. The group costs nothing when there&#39;s no overlap and pays off the moment there is — free insurance, not a magic &quot;re-entry is now free&quot; button. The cold start on an isolated re-entry, we simply accept: it lands on a natural loading boundary, and we measured it as acceptable on our device mix.</li></ul><p>The honest cost: memory. Each running engine has a footprint, and on low-end Android devices — a meaningful share of users in our market — rapid flow-to-flow transitions where two engines briefly overlap are something we watch. We also render with RenderMode.texture rather than surface, trading a little raw performance for the ability to composite Flutter cleanly inside native view hierarchies. Neither is free; both were the right call for <em>our</em> device distribution, and you should measure yours.</p><h3>The gotcha we owe you: delay(1500)</h3><p>Every honest migration has one. Here’s ours.</p><p>First, to head off the obvious objection: yes, MethodChannel calls return values — our config call already awaits a result and runs start_app in its success callback. Getting a value back isn&#39;t the problem. The problem is <em>timing</em>: a call from native only reaches Dart once the Dart side has runsetMethodCallHandler, and nothing tells native the instant that happens. Flutter does buffer a shallow queue of incoming messages per channel, so a too-early call <em>might</em> survive until the handler registers — but that buffer is easy to overflow, so rather than trust it, the native code does this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7665ef804cad28fd0bd122cac95075e1/href">https://medium.com/media/7665ef804cad28fd0bd122cac95075e1/href</a></iframe><p>There’s no matching “wait” on the Dart side — that’s the point. The handler that would need to be listening is the same ChannelConfig.initialize() from Gist 2B, and it registers on its own schedule, with nothing telling native when it&#39;s actually done.</p><p>It waits a fixed 1.5 seconds and hopes Dart is ready. Usually it is. On a cold start on a slow device, 1.5 seconds is sometimes not enough and the call lands before anyone’s listening; on a fast device, it’s 1.5 seconds of the user staring at a loading shell for no reason. A race condition papered over with a magic number, and we know it.</p><p>The fixes are all things the channel already gives us — we just didn’t reach for them first:</p><ul><li><strong>Invert the handshake.</strong> After the Dart side registers its handlers, <em>it</em> calls native to announce it’s ready; native pushes config in response. Native reacts to readiness instead of guessing at it.</li><li><strong>Retry instead of wait.</strong> Our config call already has a notImplemented callback — exactly the reply you get when the handler isn&#39;t registered yet. Treat it as &quot;not ready, try again&quot; and retry with a short backoff, instead of blocking on a fixed delay.</li></ul><p>We know how to do both. delay(1500) has lost every prioritization meeting to feature work, because it <em>mostly</em> works — the most dangerous property a bug can have. If you take one thing from this series, let it be: <strong>build the ready-signal on day one, before the magic number calcifies into &quot;load-bearing.&quot;</strong></p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FGNNwrch6eoXuTs2uLo%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2Fv1.Y2lkPTc5MGI3NjExZTlscDlucWcyenI4MG1rZnZvbHUzaTdpbW5jbHJvb2Z2bTZ3eDFkcSZlcD12MV9naWZzX3NlYXJjaCZjdD1n%2FGNNwrch6eoXuTs2uLo%2Fgiphy.gif&amp;image=https%3A%2F%2Fmedia2.giphy.com%2Fmedia%2Fv1.Y2lkPTc5MGI3NjExbGx0cjRiNTg5ZnU2enpsbnMyc3B6cGJkZ3Ixc3lqMmJiZHl2YWFzdSZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw%2FGNNwrch6eoXuTs2uLo%2Fgiphy_s.gif&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="435" frameborder="0" scrolling="no"><a href="https://medium.com/media/03e2615f0375b9e6f61223e7a75b6893/href">https://medium.com/media/03e2615f0375b9e6f61223e7a75b6893/href</a></iframe><p>Shipping a hybrid app monthly means two questions every release: <em>can the Flutter team iterate without building the whole native app?</em> and <em>if a Flutter release is bad, how fast can we undo it?</em></p><p><strong>Standalone mode answers the first.</strong> The module runs on its own — flutter run with a couple of --dart-define flags (ENV, DEBUG_MODULE) — with a debug config that fakes the native side: it seeds config, caches a credential locally, and auto-logs in on subsequent launches so a developer lands directly on the screen they&#39;re building. No native toolchain, no full app build, hot reload intact. This is the same LaunchResolver seam from Part 2 doing double duty: the &quot;no native host&quot; wiring that will one day be the full app is <em>also</em> the daily development environment. The future app pays for the dev experience today.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f0f1111e387ab5b38aa07ff99d088688/href">https://medium.com/media/f0f1111e387ab5b38aa07ff99d088688/href</a></iframe><p><strong>Rollback answers the second — and it’s two-tiered, with a fast tier that needs no release.</strong> The version-pinned Maven artifact (Part 2) means a bad Flutter release reverts by changing one line in libs.versions.toml — but that still takes a build and a store round-trip. So the first line of defense isn&#39;t the build at all: it&#39;s a remote-config flag the native entry point checks <em>before</em> it launches Flutter. Flip the flag, and the next time the app fetches config, that feature opens its <strong>native</strong> implementation again — no release, no review queue, effective in minutes. The Maven revert is the deeper, permanent undo; the remote flag is the emergency brake you can pull mid-incident.</p><p>Both levers are only trustworthy because of Part 2’s Decision 1 discipline: the native implementation stays maintained until production monitoring clears the Flutter version. During the window where you’d actually pull either one, the native fallback is still correct — which is the entire reason we keep it wired to a live flag instead of deleting it the day the Flutter version ships.</p><p><strong>Testing runs on both sides of the bridge, with different tools.</strong> The native host keeps its existing gate — a CI rule enforcing a line-coverage floor on ViewModels and repositories. The Flutter module tests its logic with riverpod_test and mocktail, and — because of the provider-override seam — a feature&#39;s behavior can be exercised with the native bridge swapped for a fake through the very same mechanism that swaps it for the real thing in production. Parity verification is mostly manual per feature during the monitoring window: the native and Flutter versions run side by side, and the Flutter one only &quot;wins&quot; the feature once its metrics match.</p><h3>Results, honestly</h3><p>This migration was still in progress when I left the company, so I can’t responsibly claim final metrics around delivery speed, engineering cost, or long-term stability. Rather than invent numbers, I’d rather describe what we had already validated.</p><p>By the time I moved on:</p><ul><li>The migration strategy had proven technically viable. Multiple production features were already running through the Flutter module without requiring a full application rewrite.</li><li>The architecture scaled beyond a proof of concept. New migrated features followed the same gateway and bridge instead of introducing one-off integrations.</li><li>The team could develop Flutter features independently in standalone mode while still integrating them into the native application.</li><li>The rollback strategy, deployment pipeline, and monthly release process had been established, allowing Flutter features to be released incrementally rather than in a single “big bang” migration.</li></ul><p>What I can’t honestly claim are the final business outcomes. The migration continued after I left, so I don’t know the eventual reduction in development cost, feature lead time, or team size. Those are numbers only the remaining team can measure.</p><p>Even without those metrics, the experience reinforced one conclusion for me: a successful add-to-app migration isn’t defined by how quickly you rewrite an application. It’s defined by whether each migrated feature makes the next migration easier than the previous one.</p><p><strong>What we’d do differently:</strong> build the ready signal instead of delay(1500) on day one; decide the native-code freeze policy <em>before</em> the first feature ships rather than discovering it under a production incident; and write down the &quot;parked feature&quot; rule early, so a stalled migration reads as a known state rather than a loose end.</p><h3>The whole series, in one line</h3><p>Add-to-app isn’t a way to <em>add</em> Flutter to your app. Done well, it’s a way to <em>replace</em> your app — one feature at a time, with the users none the wiser and the exit ramp built before you take the first step.</p><p>Thanks for reading. If you’re staring down the same migration and want to compare notes on any of this — the handoff, the engine lifecycle, or talking yourself out of your own delay(1500) — the comments are open.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=18f4d100fc9d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Migrating to Flutter Without a Rewrite, Part 2: Building a Module That’s Built to Disappear]]></title>
            <link>https://medium.com/@muhammadrisky1401/migrating-to-flutter-without-a-rewrite-part-2-building-a-module-thats-built-to-disappear-55f0fdc4eeff?source=rss-8cd4c1cce7e9------2</link>
            <guid isPermaLink="false">https://medium.com/p/55f0fdc4eeff</guid>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[software-architecture]]></category>
            <dc:creator><![CDATA[Muhammad Rizky]]></dc:creator>
            <pubDate>Thu, 23 Jul 2026 13:10:52 GMT</pubDate>
            <atom:updated>2026-09-10T03:40:09.133Z</atom:updated>
            <content:encoded><![CDATA[<h4><em>Three strategic decisions, and the architecture inside the module they produced — from a single gateway shipped like an SDK, to two routers nested one inside the other on purpose.</em></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FAqU9cIKLZKLeKEoqFjIJg.png" /></figure><p>Part 1 ended on a promise: choosing Flutter was the easy part.</p><p>The real work was making the migration invisible to users while keeping the transition predictable for the engineers who have to build, test, release, and operate it.</p><p>We defined “invisible” as a set of invariants: authentication and device identity must survive the boundary, security-sensitive capabilities must keep working, navigation and lifecycle must remain coherent, analytics and operational tooling must continue to identify the same product journey, and every migrated feature must remain independently reversible while the migration is in progress.</p><p>This part is about the architecture that makes those invariants possible. Three decisions carry most of the weight. Each one trades something away, but together they give us a migration boundary that can exist for months without becoming the architecture we have to live with forever.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*q097ErPQueEXYK6DzpcxFA.png" /></figure><h3>Decision 1: One gateway, one contract</h3><p>For our Add-to-App setup, we chose to consume a single Flutter module as the migration boundary. That still left the decisions that mattered.</p><p>One platform channel, or a channel per feature? Features as routes in one codebase, or independently versioned packages that only meet at build time? One Dart entry point, or one per flow?</p><p>A single module can still be fragmented internally into exactly the coordination problems we are trying to remove. We chose to minimize the integration surface: a single Flutter gateway module containing every migrated feature as internal routes behind one channel contract, paired with thin native entry activities — one small Kotlin module per feature on the host side.</p><p>Each entry activity does exactly three things:</p><ol><li>Spin up a Flutter engine,</li><li>Push configuration across the platform boundary,</li><li>Tell Flutter which route to open.</li></ol><p>Nothing else lives there. No business logic. No feature state. No duplicated navigation logic beyond telling Flutter which entry point to open and receiving the result back.</p><p>Part 1 showed the module-level direction: native feature implementations are gradually retired in favor of thin Flutter host modules. What that diagram doesn’t show is what backs the “one contract” half of the claim. It isn’t just a convention.</p><p>There is exactly one MethodChannel, initialized once, with a chain-of-responsibility list of feature-scoped handlers registered at startup:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/333f65ae385174171f4b7e0cf7c75e22/href">https://medium.com/media/333f65ae385174171f4b7e0cf7c75e22/href</a></iframe><p>Adding a feature to the migration is adding one handler to that list — not wiring a new channel, not touching the ones that already exist:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/636e200593d41d6c33c07efa32fba73e/href">https://medium.com/media/636e200593d41d6c33c07efa32fba73e/href</a></iframe><p>That’s the entire integration surface for a new feature, on the Flutter side: one class, oneswitch, one route. The corresponding native activity is symmetrically small — it exists to launch the engine and get out of the way, not to reimplement anything. (What crosses that channel at runtime — session tokens, config, the handshake sequence — is deliberately out of scope here; that&#39;s a later part&#39;s subject, once the bridge itself is under discussion rather than the shape of the module.)</p><p><strong>What happens to the native implementation?<br></strong>Once its Flutter replacement ships, the old native feature does not disappear immediately. Its lifecycle is:</p><blockquote><strong>Active → Flutter replacement monitored → native implementation frozen → rollback target → deleted.</strong></blockquote><p>The old implementation continues receiving critical fixes while the Flutter version is under production monitoring.</p><p>Only after the Flutter feature is considered safe do we freeze the native implementation. From that point forward, it exists as a rollback target rather than as an actively developed implementation.</p><p>This matters because rollback is only useful if the thing you’re rolling back to is still trustworthy.</p><p>The double-maintenance window is therefore deliberate and bounded. It ends based on a production-safety decision rather than an arbitrary calendar date.</p><p><strong>Why consolidation wins for a migration</strong> (as opposed to a greenfield multi-team product):</p><ul><li><strong>One bridge to test.</strong> Every native↔Flutter call goes through one MethodChannel and its handler chain — not N contracts drifting apart, the same disease we were curing.</li><li><strong>Features share everything by default.</strong> Design system, networking, storage, session — inside one module they’re ordinary imports; across modules they’d be integration work.</li><li><strong>The endgame is one app.</strong> A per-feature module fleet would need merging <em>back</em> into one — scheduling a second migration at the end of the first.</li></ul><p>The trade-off is honest: a single module means a single version, so every feature rides the same release train, and the module’s build grows with every migrated feature. For our team and release cadence, that coupling was acceptable because it kept the Flutter side aligned with the existing product release cycle while keeping the integration boundary small.</p><h3>Decision 2: Ship the module as a versioned artifact, not as source</h3><p>Flutter’s Add-to-App workflow allows the module to be built alongside the host or consumed as compiled artifacts. We chose the latter. The Android side consumes Flutter as AARs published to an internal Maven repository, pinned through the Gradle version catalog much like a third-party SDK:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/dbab3a8c2bebe608fe086c4e226ce661/href">https://medium.com/media/dbab3a8c2bebe608fe086c4e226ce661/href</a></iframe><p>This decision separated the Flutter build environment from the native host environment.:</p><ul><li><strong>Native engineers never install Flutter.</strong> No SDK, no Dart toolchain, no flutter doctor in the Android team&#39;s onboarding. The Flutter module arrives in their build exactly the way a payment SDK does. Adoption friction on the host team dropped to zero.</li><li><strong>Rollback is a one-line diff.</strong> The version catalog pins each environment to an exact artifact version with Gradle’s strictly(). A bad Flutter release in production? Revert one line inlibs.versions.toml, rebuild, ship. No revert-the-merge archaeology across two repos.</li><li><strong>Environments are explicit.</strong> Production pins a stable version, while development can float against a continuously published development artifact so feature branches can integrate against the latest Flutter work. Debug and release AARs are wired per build type across the host application’s product flavors.</li><li><strong>Clean team boundary.</strong> The Flutter team releases like an SDK vendor: build, version, publish, changelog. The native team consumes. Responsibility for a regression is legible from the version bump that introduced it.</li></ul><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2F1BFxCACn4LQJi4HPWv%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2Fv1.Y2lkPTc5MGI3NjExaHBtY3hwdzlsem1yNWRnOTdoYXNoY3BmbXAzbXFrZnA2enV6MzBuZCZlcD12MV9naWZzX3NlYXJjaCZjdD1n%2F1BFxCACn4LQJi4HPWv%2Fgiphy.gif&amp;image=https%3A%2F%2Fmedia1.giphy.com%2Fmedia%2Fv1.Y2lkPTc5MGI3NjExenhuNTI3NDMzeXoxdHBuNmFkanpnaXg4aDdpZGEwbmtxNTFxaTM1MiZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw%2F1BFxCACn4LQJi4HPWv%2Fgiphy_s.gif&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="244" frameborder="0" scrolling="no"><a href="https://medium.com/media/4358a776b051022f240225acca59e258/href">https://medium.com/media/4358a776b051022f240225acca59e258/href</a></iframe><p>The cost: iteration across the boundary is slower. Changing a channel contract means publish-then-bump instead of one atomic commit, and the two sides of the bridge live in different repos with different reviewers. A standalone debug mode compensates for a lot of this — worth a full explanation later in the series, alongside how we test and roll out hybrid releases.</p><h3>Decision 3: Build the exit ramp on day one</h3><p>The most consequential decision doesn’t show up in any Gradle file. It’s in the Flutter module’s lib/ layout:</p><pre>lib/<br>├── app/        # the future full Flutter app: go_router, DI, features, startup<br>├── gateway/    # the add-to-app shell: channel handlers, native-facing routes<br>└── main.dart   # standalone / full-app entrypoint</pre><p>The module has two runtime environments but one feature architecture.</p><p>gateway/ is everything that exists <em>because</em> we&#39;re embedded in a native host: the method-channel plumbing, per-feature handlers, and a plain-Navigator routing shell that native drives.</p><p>app/ is the application we&#39;re actually building: features, go_router, dependency injection, startup — written as if the native host were already gone. (Yes, that means two routers live in one codebase on purpose — go_router for the app that&#39;s coming, Navigator for the shell that exists only until it arrives. More on that nesting shortly.)</p><p>A LaunchResolver decides at startup which world we&#39;re in — embedded in native, running standalone for development, or (one day) running as the full app — and wires dependencies accordingly.</p><p>Capabilities that still live in native, such as authentication, sit behind an interface with two implementations:</p><ul><li>one that calls through the platform channel,</li><li>one implemented entirely in Dart.</li></ul><p>Swapping them is a provider override rather than a feature refactor.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f099a5cbef3f53da4b5c959284b7512b/href">https://medium.com/media/f099a5cbef3f53da4b5c959284b7512b/href</a></iframe><p>That provider is the actual migration seam. A feature depends on the <em>interface</em> authenticationInvokeMethodProvider and never branches on</p><blockquote>&quot;am I embedded?&quot;</blockquote><p>It simply receives whichever implementation LaunchResolver configured at startup. Behind the interface sit two of them. Take &quot;a login just completed&quot;:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/09fac74af612d8606158d658409a634c/href">https://medium.com/media/09fac74af612d8606158d658409a634c/href</a></iframe><p>The feature calls closeLogin(result) and never knows which of these runs. The <em>default</em> provider is the channel implementation — because embedded is today&#39;s reality — and provideOverrides() swaps in the Flutter one only when there&#39;s no native host. The day the native host disappears, LaunchResolver changes; the features that consume it don&#39;t.</p><p><strong>Where the toggle actually fires.</strong> provideOverrides() is read in exactly one place — the module&#39;s rootProviderScope, inside mainApp():</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/66d760e9d90f9f04844ebd4c7ac7ca58/href">https://medium.com/media/66d760e9d90f9f04844ebd4c7ac7ca58/href</a></iframe><p>Both run modes reach this same function. Standalone calls mainApp() directly from main(); embedded gets there one hop later, when a gateway route boots mainApp() for the feature native asked for (that nesting is the routing section&#39;s subject, below). Either way, mainApp() — and its one ProviderScope — runs. There is no &quot;embedded path with no ProviderScope&quot;; there&#39;s one override site both doors arrive at.</p><p>What differs is only what provideOverrides() <em>returns</em>. Embedded, it returns [] — because the default implementation behind each provider is already the channel-backed one, so there&#39;s nothing to swap. The overrides only carry weight when there&#39;s no native host at the other end: standalone debug, or the eventual full app. That&#39;s exactly why the flip works: the &quot;no native host&quot; wiring isn&#39;t invented at migration time — it already runs every day in debug. Full migration just makes it the only case.</p><p>The principle: <strong>add-to-app is a transition state, and the code should know it.</strong> When the last native screen falls, the flip is: stop building AARs, start building an app — gateway/ gets deleted, app/ gets promoted, and no feature code moves.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FbRKM4yqBFJ5JQEsxRr%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2Fv1.Y2lkPWVjZjA1ZTQ3a3M4bW9wZ2d3aTZqY2hnMDlvOWQ0MW11NzlxamR5Zmc3dmczMzg0byZlcD12MV9naWZzX3NlYXJjaCZjdD1n%2FbRKM4yqBFJ5JQEsxRr%2Fgiphy.gif&amp;image=https%3A%2F%2Fmedia1.giphy.com%2Fmedia%2Fv1.Y2lkPTc5MGI3NjExMjV6b3kwcW83cmFqd25taXBucHpjcjdtcmw0ZWI4ZXVhNTdrcXN2ZiZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw%2FbRKM4yqBFJ5JQEsxRr%2Fgiphy_s.gif&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="313" frameborder="0" scrolling="no"><a href="https://medium.com/media/717c34c76fac4e1033cea4dcf2b5b2d2/href">https://medium.com/media/717c34c76fac4e1033cea4dcf2b5b2d2/href</a></iframe><p>Without this split, the natural gravity of add-to-app pulls every feature into coupling with the bridge — and the “temporary” hybrid architecture becomes the permanent one.</p><h3>What we explicitly rejected</h3><p>For completeness, the strategies we considered and dropped:</p><ul><li><strong>Big-bang rewrite</strong> — ruled out in Part 1: no feature freeze, no user disruption, no compliance regression. A parallel rewrite of a monthly-shipping regulated app is a bet that nothing changes for a year. Everything changes every month.</li><li><strong>New features in Flutter, old features stay native forever</strong> — the “strangler fig without the strangling” pattern. It caps the payoff: you keep both codebases and both teams indefinitely, which is the tax we set out to eliminate.</li><li><strong>A fragmented single module</strong> — per-feature channels, per-feature entrypoints, independently versioned feature packages meeting only at build time. Technically possible inside the one-module constraint, but it rebuilds the coordination problem we were escaping — and the endgame is one app anyway.</li><li><strong>Building the host from Flutter source</strong> — couples native CI to the Flutter toolchain and gives up the one-line rollback. The AAR pipeline cost us a week of setup and has been repaying it monthly.</li></ul><h3>Inside the module: the architecture those decisions produced</h3><p>Three decisions gave the migration its shape: one gateway, distributed like an SDK, built to know it’s temporary. Now let’s look at what runs inside that shape — how routing actually works in a module with two personalities, the full request path from a native tap to a stored session, and the short checklist that migrating one feature comes down to.</p><h3>Two routers, nested on purpose</h3><p>The gateway/ vs app/ split extends into navigation, and this is the part that surprises people: the module runs <strong>two routers at once — one inside the other</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/566/1*ECe93Eb1RWBGkvIxUfrRNA.png" /><figcaption><strong>A Navigator hosting a go_router app. Yes, we heard ourselves.</strong></figcaption></figure><p>app/ is the real application. It owns every feature, routed by go_router (URL reflection on, for the deep links and history a standalone app will need).</p><p>gateway/ is the embedded shell. It uses a plain Navigator.</p><p>The thing to understand is what the gateway&#39;s routes actually do: <strong>they don&#39;t render features.</strong> Each one boots the app. A gateway route builder returns EntryPointInitPage(initPage: mainApp(initialLocation: &lt;feature&gt;)) — it mounts the entire go_router app, rooted at the feature native asked for:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/519dacdc5068486125b391222a0ce808/href">https://medium.com/media/519dacdc5068486125b391222a0ce808/href</a></iframe><p>So there is no second implementation of any feature. The gateway Navigator is an outer shell whose entire job is to launch the inner go_router app at a chosen entry point, on the native&#39;s command. Features are written once, inapp/; the gateway just points at them. That&#39;s why &quot;which router&quot; is never a branch inside feature code — the outer shell hands off to the inner app and gets out of the way.</p><p>You’ve already seen the inner end — mainApp(), from Decision 3, which builds MaterialApp.router on a go_router config. The outer shell is just as small:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a82c3f32e40a9c3ffc0e4138c13b2331/href">https://medium.com/media/a82c3f32e40a9c3ffc0e4138c13b2331/href</a></iframe><p>The cost is real: two routing models to hold in your head, and route names duplicated across the outer shell and the inner app kept in sync by convention, not the compiler. We keep it because the outer shell is temporary scaffolding — when native is gone, gateway/ is deleted and only go_router remains. Forcing URL semantics onto a throwaway shell, or making the future app inherit a shell router it will outgrow, both seemed worse than the nesting.</p><h3>The full path, end to end</h3><p>Every decision so far has been introduced on its own. It’s worth watching them run together, because the wiring only really makes sense as a sequence. Here’s a single login, embedded in the native app, from tap to session — each step is a piece you’ve already met:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AwV-olGpbfUkzggK7xWdeg.png" /></figure><ol><li><strong>The user taps “login” in the native app.</strong> A thin native entry activity asks the shared FlutterEngineGroup for an engine (Decision 1) and launches it into the custom Dart entrypoint, initializeChannelConfig — not main().</li><li><strong>The entrypoint wires the bridge, nothing else.</strong> It registers every feature’s BaseMethodHandler on the one channel (Decision 1) and initializes LaunchResolver (which decides run mode). No UI yet.</li><li><strong>Native pushes config, then says go.</strong> Over the channel, native sends its whole config payload — base URLs, keys, device identity, session material — which Flutter stores; only <em>then</em> does native call start_app. That ordering is deliberate (Flutter must be able to read config before the first widget builds), and it&#39;s also where the honest delay(1500) lives — native waits a fixed beat for Dart to be ready, a race we&#39;ll dissect in Part 3.</li><li><strong>start_app boots the outer shell.</strong> The handler for it calls runApp(GatewayApp()) — the thin Navigator shell. Still no feature on screen; just the shell showing a loading page.</li><li><strong>Native asks for a specific feature.</strong> It calls navigate_to_login on the channel. The authentication handler pushes the gateway&#39;s login route — whose builder boots mainApp() at the login entry point (Decision 3 / the routing section). The inner go_router app now owns the screen.</li><li><strong>The feature runs, oblivious to run mode.</strong> The login UI reads its config from CommonAppConfig (the payload from step 3) and its behavior from authenticationInvokeMethodProvider — which, embedded, resolves to the channel-backed implementation, because that&#39;s the default and provideOverrides() returned [].</li><li><strong>Login completes, and the session crosses back.</strong> The feature calls closeLogin(result). The channel-backed implementation forwards the result over the channel to native, which persists it in the session store the native app already owns. No second login, no divergent state.</li></ol><p>Now delete the native host in your head and re-read. Steps 1–5 vanish. Step 6’s provider default flips — via the override already sitting in LaunchResolver — to the pure-Dart implementation, so step 7 becomes SessionManager.saveCredential(...) plus a go_router navigation instead of a channel call. Every other line is identical. That&#39;s the whole point of the wiring: the same feature code runs in both worlds, and the seams decide which world it&#39;s in.</p><h3>What migrating a feature actually touches</h3><p>Putting it together, migrating one feature comes down to five moves:</p><ul><li><strong>Freeze new development on the native feature implementation once the Flutter version is live and under production monitoring.</strong> Keep the native code as a rollback target until the Flutter implementation has passed the agreed safety criteria.</li><li><strong>Add a thin native host module and entry activity.</strong> Engine, configuration, route. Nothing else.</li><li><strong>Add one feature handler to the existing channel chain.</strong> No new channel and no separate bridge integration.</li><li><strong>For any capability that differs between embedded and standalone runtime, define an interface with the required implementations.</strong> Default the provider to the native-backed implementation and let LaunchResolver supply the pure-Dart implementation when running without the native host.</li><li><strong>Add a gateway route that boots </strong><strong>mainApp() at the feature&#39;s entry point.</strong> The feature itself is implemented once inside app/.</li></ul><p>The migration should not require changes to features that have already completed migration. Shared infrastructure can still evolve, and bridge or contract changes still need normal regression testing, but a new feature should not create another dependency on the migration machinery.</p><p>Operational continuity is part of the migration too. Analytics, logging, crash reporting, feature flags, and rollout controls need to continue identifying the migrated flow as part of the same product journey. And the native team should only need to consume a new Flutter artifact version rather than understand the implementation inside the module.</p><h3>What’s next</h3><p>The strategy explains why this shape exists. The architecture explains what’s running inside it.</p><p>What we haven’t shown yet is what happens the moment a user actually crosses the boundary — because a gateway and a channel contract are only half the story until something real moves across them: a fresh engine spinning up mid-tap, a session token that has to survive the handoff, and a hard-coded delay(1500) in the handshake that we are still, to this day, not proud of.</p><p>Part 3 is that story — plus how we test and roll out hybrid releases without a monthly game of production roulette, and what two years of this has actually bought us.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=55f0fdc4eeff" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>