<?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 Usman Kulaha on Medium]]></title>
        <description><![CDATA[Stories by Usman Kulaha on Medium]]></description>
        <link>https://medium.com/@sparxs.818?source=rss-bd1fc36752cf------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*HDy5uo2c4ryfpqCcIvso8Q@2x.jpeg</url>
            <title>Stories by Usman Kulaha on Medium</title>
            <link>https://medium.com/@sparxs.818?source=rss-bd1fc36752cf------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 02:43:40 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@sparxs.818/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[How I Use AI Agents to Engineer More Efficient Software — Without Losing Control]]></title>
            <link>https://medium.com/@sparxs.818/how-i-use-ai-agents-to-engineer-more-efficient-software-without-losing-control-aa18eac18b95?source=rss-bd1fc36752cf------2</link>
            <guid isPermaLink="false">https://medium.com/p/aa18eac18b95</guid>
            <category><![CDATA[software-architecture]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[ai-agent]]></category>
            <dc:creator><![CDATA[Usman Kulaha]]></dc:creator>
            <pubDate>Thu, 05 Nov 2026 11:38:07 GMT</pubDate>
            <atom:updated>2026-11-05T11:38:07.034Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Building an AI-assisted engineering workflow that prioritizes software quality, architectural discipline, resource optimization, and long-term maintainability.</em></p><p><strong>AI agents can write code remarkably quickly. But generating code quickly and engineering efficient software are two very different things.</strong></p><p>As a software engineer, I am more interested in what happens after the code is generated.</p><p>Does the implementation use resources efficiently? Does it scale as data grows? Does it introduce unnecessary database operations? Does it preserve architectural boundaries? Can it recover gracefully from failures? Does it remain maintainable as new features are introduced?</p><p>These questions matter more to me than how many lines of code an AI agent can produce in a single session.</p><p>I have gradually developed an AI-assisted engineering workflow around this philosophy.</p><p>Rather than treating AI as an autonomous code generator, I use agents as specialized engineering collaborators operating within a structured system of architecture, ownership, investigation, validation, and accountability.</p><p>At the centre of that system is what I call an <strong>Application Superagent</strong>, supported by specialist module agents and a repository-based collaboration playbook.</p><p>My objective is straightforward:</p><p><strong>Use AI agents to maximize engineering resources and produce more efficient, reliable, and maintainable software — not merely to accelerate development.</strong></p><p>This is how I approach it, including the trade-offs and limitations I have encountered.</p><h3>1. Why I moved beyond conventional AI-assisted coding</h3><p>My work involves developing and maintaining ViVA Mobile, an offline-first clinical application built with Flutter.</p><p>The application supports interconnected workflows such as patient registration, clinical encounters, pharmacy, laboratory, biometrics, dashboards, and synchronization.</p><p>It operates in environments where internet connectivity can be unreliable and where access to clinical information must remain dependable.</p><p>This creates engineering constraints that go well beyond implementing functional screens.</p><p>Consider a patient synchronization process that imports more than 20,000 patient records with relationships distributed across dozens of database tables.</p><p>A straightforward implementation may successfully import those records.</p><p>But successful execution alone does not make it efficient.</p><p>The process could involve excessive database reads and writes, unnecessary model transformations, inefficient transaction boundaries, memory pressure, or competing database operations.</p><p>An AI agent might propose increasing concurrency as an optimization.</p><p>That approach could help certain stages of the pipeline, but it could also increase SQLite write contention, introduce resource pressure, or complicate recovery after interrupted transactions.</p><p>The better solution requires understanding the actual bottleneck before changing the implementation.</p><p>That distinction shaped my approach to AI-assisted engineering.</p><p>I wanted agents capable of examining the complete technical problem, evaluating alternatives, and preserving system integrity — not simply producing the first implementation that satisfies a feature request.</p><h3>2. My Application Superagent model</h3><p>At the centre of my workflow is an Application Superagent.</p><p>Its primary responsibility is to coordinate engineering work across the application.</p><p>I describe a problem, and the superagent investigates it, identifies the probable owning module, and determines whether specialized assistance is necessary.</p><p>The application has ownership areas such as:</p><ul><li>Clinics and clinical forms</li><li>Authentication and application lifecycle</li><li>Patient profiles</li><li>Storage and database integrity</li><li>Cloud and LAN synchronization</li><li>Biometrics</li><li>Laboratory and pharmacy</li><li>Network services</li><li>Dashboard and analytics</li><li>Adaptive and cross-platform UI</li></ul><p>These specialist roles are defined by engineering responsibility rather than arbitrary labels.</p><p>For example, a patient-list problem may initially appear to belong to the Clinics module.</p><p>However, investigation may reveal that the real cause is a database query, a shared BLoC state transition, or a synchronization contract.</p><p>The superagent is expected to route work based on evidence about the root cause, not merely where the problem becomes visible.</p><p>This helps prevent superficial fixes.</p><h3>More agents do not necessarily mean better engineering</h3><p>One lesson I have learned is that using more agents can actually make a workflow less efficient.</p><p>Every agent consumes resources.</p><p>It needs instructions, context, access to relevant files, and potentially an integration review.</p><p>Multiple agents working on overlapping problems can duplicate investigations, produce conflicting changes, or increase the cost of coordinating implementation.</p><p>For that reason, my default approach is to use <strong>one lead agent</strong>.</p><p>Additional agents are introduced only when the work can be meaningfully separated and delegation provides a clear engineering benefit.</p><p>Independent tasks can be investigated concurrently. Work that depends on shared contracts is sequenced appropriately.</p><p>There is also a strict ownership principle: one agent writes to a file at a time.</p><p>The purpose of specialization is not to maximize the number of active AI processes. It is to apply the appropriate engineering expertise while minimizing wasted effort and integration risk.</p><h3>3. Context management is part of resource optimization</h3><p>One easily overlooked cost in agentic development is context consumption.</p><p>An agent does not become more effective simply because it reads more files.</p><p>Loading a large architecture document, an entire module, extensive Git history, and hundreds of completed workplan entries may increase token consumption without improving the decision.</p><p>It can also bury relevant evidence beneath unrelated information.</p><p>I address this through a lightweight repository documentation structure.</p><p>My project uses several complementary documents:</p><p>DocumentPurposeAGENTS.mdConcise instructions for agent executionCOLLABORATION_PLAYBOOK.mdOwnership, routing, authorization, and coordination rulesARCHITECTURE.mdTechnical architecture, patterns, and system contractsWORKPLAN.mdActive tasks, acceptance criteria, and unresolved workUI_DESIGN_STANDARD.mdCross-platform design and interaction requirements</p><p>The documents provide continuity without requiring every agent to consume everything.</p><p>For instance, a change to a clinical form’s appearance should not require reading every database migration.</p><p>A synchronization issue should begin with relevant synchronization contracts, database implementations, logs, and tests.</p><p>Agents are instructed to search the repository first, identify the relevant implementation, and read only the necessary files or sections.</p><p>This creates a more focused investigation process.</p><p>It also reduces repeated explanations when switching between AI tools.</p><p>The project context lives with the source code rather than depending entirely on conversational memory.</p><p><strong>Efficient agentic engineering requires optimizing the context consumed to reach a correct decision — not maximizing context for its own sake.</strong></p><h3>4. Investigation before implementation</h3><p>A major source of inefficient software is solving the wrong problem.</p><p>An implementation can be technically correct yet architecturally inappropriate.</p><p>Consider a requirement to display patients who have not been enrolled in any clinical service.</p><p>One possible implementation is to load the patient list and filter the records in memory.</p><p>If the screen currently displays only 50 patients, that approach may look correct during casual testing.</p><p>But it cannot correctly represent a facility containing thousands of patients.</p><p>The better implementation applies the enrollment condition at the database-query level and preserves the filter across pagination and search.</p><p>The difference is not the amount of code written.</p><p>It is the quality of the engineering decision.</p><p>My agents therefore follow a four-stage workflow for non-trivial changes.</p><h3>Investigate</h3><p>The agent examines the relevant code, logs, architecture, existing tests, and current application behavior.</p><p>It identifies what is confirmed and what remains a hypothesis.</p><h3>Clarify genuine ambiguity</h3><p>If investigation leaves an unresolved product or technical decision, the agent asks for clarification.</p><p>It should not ask questions that can be answered by reading the implementation.</p><h3>Propose the stronger solution</h3><p>The agent evaluates whether an existing pattern or more appropriate architecture can satisfy the requirement with fewer side effects.</p><p>It should improve the implementation without introducing unnecessary abstractions.</p><h3>Explain trade-offs</h3><p>Before consequential changes, the agent evaluates performance, memory, database load, offline behavior, synchronization, shared state, and compatibility with other modules.</p><p>This creates a disciplined decision process without requiring lengthy deliberation over every minor change.</p><h3>5. Optimizing software resources, not just developer effort</h3><p>For me, resource efficiency exists at two levels.</p><p>The first is the efficiency of the engineering process itself.</p><p>The second — and more important — is the efficiency of the software being produced.</p><h3>Engineering resource efficiency</h3><p>I want agents to avoid unnecessary investigations, repeated test execution, duplicate context retrieval, overlapping work, and excessive documentation.</p><p>The objective is to direct engineering attention toward decisions that materially improve the product.</p><h3>Runtime resource efficiency</h3><p>I also want agents to consider the actual resources consumed by the application.</p><p>These include:</p><ul><li>CPU usage</li><li>Memory allocation</li><li>Database reads and writes</li><li>Network bandwidth</li><li>Battery consumption</li><li>Storage utilization</li><li>Background processing</li><li>Connection-pool contention</li><li>UI rendering and rebuild costs</li></ul><p>This distinction is important.</p><p>An agent could generate a feature very efficiently while producing an implementation that wastes significant resources every time a user interacts with it.</p><p>That is not the type of efficiency I am optimizing for.</p><h3>A practical example: database synchronization</h3><p>Suppose an initial synchronization process takes approximately 15 minutes.</p><p>The wrong question is:</p><p><em>How do we make all database operations execute concurrently?</em></p><p>The better question is:</p><p><em>Where is the time actually being spent, and which changes would improve throughput without compromising integrity?</em></p><p>I would expect the agent to examine parsing time, database write volume, transaction boundaries, batch sizes, indexes, connection-pool behavior, and repeated transformations.</p><p>An optimization might involve reducing redundant operations, batching compatible writes, minimizing repeated queries, or moving CPU-heavy parsing away from the UI isolate.</p><p>However, each proposal must be evaluated against SQLite’s concurrency model, memory limitations, and the application’s recovery requirements.</p><p>The outcome should be measured using comparable data and device conditions.</p><p>A shorter execution time is valuable, but not if it results in missing records, duplicated relationships, broken retries, or an unresponsive application.</p><p><strong>Performance improvements are only improvements when they preserve correctness.</strong></p><h3>6. SOLID principles help agents maintain architectural discipline</h3><p>AI agents can generate architectural abstractions almost effortlessly.</p><p>Interfaces, repositories, services, factories, coordinators, and dependency injection structures can all be created within a single session.</p><p>But additional abstraction is not automatically better architecture.</p><p>I use SOLID principles as practical guidelines rather than instructions to continuously split classes.</p><p>In my clinical workflow system, I have used AI-assisted refactoring to separate patient registration from service enrollment, isolate validation logic, narrow persistence interfaces, and extract reusable workflow coordinators.</p><p>One example is the new-patient registration sequence.</p><p>The application must register the patient, update the patient state, ask whether the patient should be enrolled in a selected service, and begin enrollment only when confirmed.</p><p>A coordinator can own this sequence, while UI components handle presentation and repositories handle persistence.</p><p>That separation enables more focused testing and reuse.</p><p>But I expect agents to stop extracting components when the remaining code is cohesive.</p><p>An interface that merely forwards calls without introducing a meaningful contract does not necessarily improve the design.</p><p>The aim is to reduce coupling, clarify responsibilities, and make future changes safer.</p><p>Not to maximize the number of architectural layers.</p><h3>7. Blast-radius analysis is essential for efficient maintenance</h3><p>A narrow bug fix can introduce a much larger regression when shared dependencies are overlooked.</p><p>Before modifying shared models, queries, coordinators, widgets, or utilities, I require agents to inspect their consumers.</p><p>A clinical workflow may have different phone and Chromebook presentation components.</p><p>A validation pattern may exist across multiple service forms.</p><p>A shared patient contract may be consumed by Clinics, Patient Profile, Biometrics, and Synchronization.</p><p>Changing one implementation without checking the others can produce inconsistent behavior.</p><p>Blast-radius analysis helps identify these dependencies before code is modified.</p><p>But it also introduces a trade-off.</p><p>An agent could discover many related areas and begin refactoring them unnecessarily.</p><p>My rule is to distinguish necessary compatibility work from opportunistic improvement.</p><p>Changes required to preserve correctness belong in the task.</p><p>Unrelated enhancements should be recorded separately rather than silently expanding the implementation.</p><p>This keeps maintenance focused.</p><h3>8. I scale validation according to engineering risk</h3><p>Software efficiency also depends on the resources consumed by development and validation.</p><p>Running every available check after every small change can be wasteful.</p><p>Running too few checks can be dangerous.</p><p>I use progressive validation, with the depth of testing determined by the risk and reach of the change.</p><p>Risk levelTypical changesExpected validationLowStyling, labels, documentationFormatting, diff checks, relevant focused checksMediumBLoC logic, feature queries, shared componentsUnit/widget tests, analysis, dependency checksHighDatabase migrations, clinical submissions, synchronization, authenticationContract tests, integration checks, failure recovery, targeted device/backend verification</p><p>The classification is based on consequences, not code size.</p><p>A five-line database migration may be riskier than a substantial UI redesign.</p><p>High-risk operations require additional safeguards such as transaction verification, retry testing, schema compatibility, and recovery analysis.</p><p>This approach makes testing more intentional.</p><p>It also prevents agents from repeatedly rerunning unchanged checks merely to produce a more impressive completion report.</p><h3>9. Evidence matters more than agent confidence</h3><p>One risk of AI-assisted development is the tendency for assistants to describe a solution as successful before sufficient validation has occurred.</p><p>I explicitly distinguish between implementation and verification.</p><p>Code written is not the same as code tested.</p><p>Passing tests is not the same as a successful build.</p><p>A successful build is not the same as physical-device verification.</p><p>And physical-device verification does not automatically establish correct behavior against a live backend under unreliable network conditions.</p><p>Each claim must be supported by evidence.</p><p>If automated tests pass but static analysis stalls, that limitation should appear in the final report.</p><p>If a synchronization optimization is tested using mocked repositories, the agent should not describe it as production-data verified.</p><p>I also expect agents to separate confirmed root causes from probable explanations.</p><p>This prevents architectural decisions from being built on unsupported assumptions.</p><p>Reliable engineering needs observable results, not convincing summaries.</p><h3>10. I make recovery and handoffs part of the architecture of work</h3><p>Agent sessions are not permanent.</p><p>A context window may expire, execution may be interrupted, or I may switch between Claude, Codex, Copilot, and another tool.</p><p>Project continuity should not depend on one assistant remembering everything.</p><p>My workflow uses repository documentation and structured handoffs to preserve essential decisions.</p><p>For substantial tasks, the handoff records the implementation state, affected contracts, validation results, unresolved risks, and next safe steps.</p><p>This is particularly important for database and synchronization work.</p><p>If an agent partially modifies a migration or persistence workflow, another agent must be able to determine what has changed before continuing.</p><p>It should not assume that incomplete code is safe simply because a previous summary described the task as nearly finished.</p><p>I also preserve Git accountability.</p><p>Agents cannot discard unrelated modifications, silently commit changes, or assume that a dirty worktree belongs to their current task.</p><p>This allows AI tools to collaborate within the same engineering environment without treating it as disposable.</p><h3>11. Where this approach has limitations</h3><p>A structured agent workflow introduces its own costs.</p><p>Specialist coordination consumes context and time. Documentation can become stale. Agents can still misdiagnose problems. Automated tests can miss real-world failures.</p><p>There are also situations where delegation is less efficient than letting one capable agent complete the work.</p><p>For these reasons, I avoid treating agent orchestration as an end in itself.</p><p>I use the smallest effective number of agents, minimize unnecessary context, and require a clear reason before introducing more complexity.</p><p>I also recognize that performance optimization involves trade-offs.</p><p>Reducing database calls may increase memory requirements. Larger batches may improve throughput but lengthen transaction boundaries. Additional caching may reduce repeated reads but introduce invalidation problems.</p><p>No optimization should be accepted simply because it improves one metric.</p><p>The broader effect on application reliability and maintainability must be considered.</p><p>For healthcare applications, data integrity and recoverability take priority over marginal execution-time improvements.</p><p>The goal is not to eliminate every trade-off.</p><p>It is to make those trade-offs visible and choose deliberately.</p><h3>12. How I evaluate whether the workflow is effective</h3><p>I do not consider generated code volume a useful measure of engineering productivity.</p><p>Instead, I look at outcomes such as:</p><ul><li>Whether implementations avoid redundant database and network operations.</li><li>Whether application behavior remains reliable under offline conditions.</li><li>Whether architectural boundaries remain understandable.</li><li>Whether changes introduce regressions or unnecessary dependencies.</li><li>Whether performance improvements are measurable.</li><li>Whether another engineer or agent can maintain the implementation without reconstructing its history.</li><li>Whether development resources are being consumed on meaningful work rather than duplicated effort.</li></ul><p>I also consider runtime characteristics such as database throughput, memory pressure, UI responsiveness, and recovery behavior.</p><p>Not all of these improvements can be attributed directly to AI agents, and not all have been quantified.</p><p>But they provide a more meaningful framework for evaluating the system than simply counting how many tasks an agent completed.</p><h3>My biggest lesson: optimize the engineering outcome</h3><p>The more I work with AI agents, the less interested I become in how quickly they generate code.</p><p>What matters is whether they help me make better engineering decisions.</p><p>A well-designed agent workflow should reduce unnecessary resource consumption, prevent repeated mistakes, preserve architectural consistency, and improve the reliability of the resulting software.</p><p>That sometimes means writing less code.</p><p>Sometimes it means rejecting an attractive optimization because its failure modes are unacceptable.</p><p>Sometimes it means conducting a deeper investigation before implementation.</p><p>And sometimes it means using one agent instead of five.</p><p>My Application Superagent model is not an attempt to remove engineering judgment from software development.</p><p>It is a way to make that judgment more systematic, repeatable, and supported by the right tools.</p><p>The agents investigate, reason, implement, validate, and document.</p><p>The architecture defines the boundaries.</p><p>The playbook establishes the rules.</p><p>Evidence determines what has actually been achieved.</p><p>I remain responsible for the product and its technical direction.</p><p><strong>The real value of AI agents is not their ability to produce software faster. It is their potential to help us produce more efficient software while making better use of the engineering resources available to us.</strong></p><p>That is the kind of AI-assisted development I am working toward.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=aa18eac18b95" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[I Built flutter_lan_sync: Secure Peer-to-Peer Data Synchronization for Flutter Without the Internet]]></title>
            <link>https://medium.com/@sparxs.818/i-built-flutter-lan-sync-secure-peer-to-peer-data-synchronization-for-flutter-without-the-internet-4be38cd7cc47?source=rss-bd1fc36752cf------2</link>
            <guid isPermaLink="false">https://medium.com/p/4be38cd7cc47</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[flutter]]></category>
            <dc:creator><![CDATA[Usman Kulaha]]></dc:creator>
            <pubDate>Wed, 23 Sep 2026 13:59:07 GMT</pubDate>
            <atom:updated>2026-09-23T13:59:07.402Z</atom:updated>
            <content:encoded><![CDATA[<p>What happens when your Flutter application needs to exchange data between devices — but the internet is unavailable?</p><p>Not slow.</p><p>Not unreliable.</p><p>Completely unavailable.</p><p>This is a problem I have spent a lot of time thinking about while building offline-first applications.</p><p>In many environments, particularly healthcare facilities and other field operations, losing internet connectivity should not mean losing the ability to work.</p><p>A Wi-Fi network may still be available. Two devices may be sitting in the same building, connected to the same router, but unable to communicate because the application architecture assumes every synchronization operation must pass through a cloud server.</p><p>I wanted to remove that dependency.</p><p>That work eventually became <strong>flutter_lan_sync</strong>, and I have now published the package for other Flutter developers to use.</p><p>Current release:</p><pre>dependencies:<br>  flutter_lan_sync: ^0.1.1</pre><p>The package is available on <strong>pub.dev</strong>, with the project also available through <strong>UK818/Flutter_LAN_sync on GitHub</strong>.</p><h3>The problem: offline should not mean isolated</h3><p>Offline-first applications usually solve one important problem:</p><blockquote><em>The user can continue working when the server cannot be reached.</em></blockquote><p>That is great.</p><p>But there is another problem.</p><p>Imagine two tablets being used inside the same clinic, warehouse, field office, school, or remote operation.</p><p>Both applications work offline.</p><p>Both devices are collecting data.</p><p>Both devices are connected to the same local Wi-Fi network.</p><p>But because there is no internet connection, neither device knows what is happening on the other.</p><p>They are offline-capable, but still isolated.</p><p>I wanted devices on the same local network to be able to discover each other and securely exchange data <strong>without requiring cloud connectivity</strong>.</p><p>That became the foundation of flutter_lan_sync.</p><h3>What does flutter_lan_sync do?</h3><p>At a high level, the package allows Flutter applications on the same local Wi-Fi network to discover one another and exchange structured application data.</p><p>There are two main workflows.</p><h3>1. Explicit item transfer</h3><p>An application can send complete structured objects to another device.</p><p>For example:</p><ul><li>patient records</li><li>appointments</li><li>forms</li><li>inventory records</li><li>field survey submissions</li><li>configuration objects</li><li>tasks</li><li>other JSON-serializable records</li></ul><p>The receiving device does not have to accept the data automatically.</p><p>Incoming transfers can be placed into a pending state and presented to the receiving user for approval before the host application persists them.</p><p>This is useful where data movement needs to remain visible and intentional.</p><h3>2. Background CRDT synchronization</h3><p>The second mode is designed for synchronization between devices that are already trusted.</p><p>Instead of continuously transferring complete database records, the package can work with <strong>field-level change logs</strong>.</p><p>Each change includes information such as:</p><ul><li>entity</li><li>entity ID</li><li>field</li><li>previous value</li><li>new value</li><li>originating device</li><li>Hybrid Logical Clock timestamp</li></ul><p>The synchronization layer can then reconcile changes from multiple devices.</p><p>For ordinary fields, the package uses deterministic last-write-wins rules based on Hybrid Logical Clock ordering.</p><p>Append-only fields can instead be union-merged so entries are not silently discarded.</p><p>The goal is not simply:</p><blockquote><em>Copy database A into database B.</em></blockquote><p>It is:</p><blockquote><em>Determine what changed, exchange those changes, and resolve concurrent edits predictably.</em></blockquote><p>That distinction becomes increasingly important as an offline system grows.</p><h3>Device discovery without an internet connection</h3><p>One of the first challenges was discovery.</p><p>How does Device A know Device B exists if there is no central server coordinating them?</p><p>flutter_lan_sync uses UDP broadcast discovery on the local Wi-Fi network.</p><p>A device periodically announces a small beacon containing enough information for another device to discover it.</p><p>The devices must be on the same local network, but they do not need:</p><ul><li>internet connectivity</li><li>DNS</li><li>a cloud API</li><li>a discovery server</li></ul><p>Discovery itself does not grant access.</p><p>Finding another device is only the beginning.</p><p>The devices still need to authenticate and establish encrypted communication.</p><h3>Security had to be part of the architecture</h3><p>Peer-to-peer networking becomes much less interesting if any application on the Wi-Fi network can connect and start sending data.</p><p>So the synchronization protocol includes multiple security layers.</p><h3>X25519 key exchange</h3><p>Devices establish shared cryptographic material using <strong>X25519 elliptic-curve Diffie-Hellman</strong>.</p><h3>HKDF-SHA256</h3><p>The shared secret is passed through <strong>HKDF-SHA256</strong> to derive the encryption key used by a specific device pair.</p><h3>AES-256-GCM</h3><p>Application payloads are encrypted using <strong>AES-256-GCM</strong>.</p><p>AES-GCM provides both confidentiality and authenticated integrity, meaning modified ciphertext should fail authentication rather than being silently processed.</p><h3>Application identity verification</h3><p>The handshake also verifies that the peer belongs to the expected application environment.</p><p>Applications can additionally scope communication using values such as:</p><ul><li>application identity</li><li>facility</li><li>deployment instance</li></ul><p>This is especially important in systems where two installations may use the same software but must not automatically exchange data.</p><h3>Device approval</h3><p>Discovering a device does not automatically make it trusted.</p><p>Devices can be approved and later revoked.</p><p>For explicit item transfers, the receiving application can also require the user to accept the incoming data before it reaches the application’s persistence layer.</p><p>Security is therefore not treated as an additional feature sitting on top of synchronization.</p><p>It is part of the synchronization model itself.</p><h3>The host application still owns its data</h3><p>One design decision I consider important is that flutter_lan_sync does not attempt to define your application models.</p><p>A transferred item’s data can be represented as:</p><pre>Map&lt;String, dynamic&gt;</pre><p>That means the package does not need to understand whether you are transferring:</p><pre>Patient<br>Appointment<br>Invoice<br>Survey<br>InventoryItem<br>Task</pre><p>or something completely different.</p><p>The receiving application gets the data and decides how to validate, deserialize, and persist it.</p><p>For example:</p><pre>await LanSync.initialize(<br>  LanSyncConfig(<br>    appSecret: appSecret,<br>    packageName: &#39;com.example.app&#39;,<br>    deviceName: &#39;Clinic Tablet&#39;,<br>    facilityId: &#39;facility-123&#39;,<br>    instanceType: &#39;production&#39;,<br>    onReceive: (items) async {<br>      // Validate and persist records here.<br>    },<br>  ),<br>);</pre><p>This separation allows the networking package to remain generic while the host application retains responsibility for its domain rules.</p><h3>Where could this be useful?</h3><p>Healthcare was one of the environments that shaped my thinking around this problem, but the architecture itself is not healthcare-specific.</p><p>The same problem appears anywhere devices need to continue collaborating when external connectivity disappears.</p><p>For example:</p><p><strong>Field operations</strong></p><p>Teams collecting data in areas with unreliable connectivity.</p><p><strong>Warehouses</strong></p><p>Multiple handheld devices operating inside the same facility.</p><p><strong>Emergency response</strong></p><p>Teams working on a temporary local network when external infrastructure is unavailable.</p><p><strong>Schools</strong></p><p>Devices exchanging information over an internal network with limited internet access.</p><p><strong>Retail</strong></p><p>Local terminals that need limited device-to-device exchange during connectivity interruptions.</p><p><strong>Remote applications</strong></p><p>Any system where local connectivity is more dependable than internet connectivity.</p><p>The core idea is simple:</p><blockquote><em>If two trusted devices can already reach each other locally, cloud availability should not always determine whether they can collaborate.</em></blockquote><h3>Local synchronization does not replace the cloud</h3><p>This is an important distinction.</p><p>I do not see LAN synchronization as a replacement for normal server-side synchronization.</p><p>They solve different problems.</p><p>A cloud backend remains important for things such as:</p><ul><li>centralized authorization</li><li>long-term backup</li><li>organization-wide data distribution</li><li>analytics</li><li>reporting</li><li>disaster recovery</li><li>cross-location synchronization</li></ul><p>LAN synchronization provides another path.</p><p>Instead of:</p><pre>Device<br>   ↓<br>Internet<br>   ↓<br>Cloud<br>   ↓<br>Internet<br>   ↓<br>Device</pre><p>a local exchange can become:</p><pre>Device<br>   ↓<br>Local Wi-Fi<br>   ↓<br>Device</pre><p>And when external connectivity returns, the wider cloud synchronization architecture can continue.</p><p>That is the model I find interesting:</p><p><strong>local-first resilience combined with eventual centralized synchronization.</strong></p><h3>There are still trust boundaries</h3><p>Publishing infrastructure code also means being clear about what it does not solve.</p><p>A device that a user deliberately approves becomes part of the trust boundary.</p><p>LAN traffic should not be treated as a substitute for server-side authorization, auditing, validation, and backup policies.</p><p>The host application should also validate incoming data before persisting it.</p><p>And application secrets should be supplied through an appropriate protected release mechanism rather than casually committed to source control.</p><p>Offline-first architecture does not eliminate security responsibilities.</p><p>It changes where some of those responsibilities need to be handled.</p><h3>Why open-source it?</h3><p>The package grew from a problem I encountered while working on real offline-first systems.</p><p>But once the networking, discovery, encryption, approval, transfer, and conflict-resolution concerns were separated from the domain-specific application code, it became clear that the solution could be useful beyond one project.</p><p>That is why I extracted it into a reusable Flutter package.</p><p>My hope is that another Flutter developer working on an offline-first application does not have to start this particular problem from zero.</p><p>The current release is:</p><pre>flutter_lan_sync: ^0.1.1</pre><p>It is still early, and I expect the design to evolve as it is tested against more applications, network configurations, operating systems, and synchronization patterns.</p><p>If you are building offline-first Flutter applications, I would particularly value feedback around:</p><ul><li>peer discovery reliability</li><li>multi-device synchronization</li><li>CRDT strategies</li><li>security design</li><li>developer API ergonomics</li><li>large data transfers</li><li>unusual Wi-Fi environments</li><li>iOS, Android, and macOS behavior</li></ul><p>Open source becomes valuable when other engineers test assumptions that made perfect sense to the original author.</p><p>That is the stage I am interested in now.</p><p><strong>Package:</strong> flutter_lan_sync on pub.dev<br><strong>Repository:</strong> UK818/Flutter_LAN_sync on GitHub</p><p>If you are working on offline-first Flutter systems, I would love to hear what synchronization problems you are solving.</p><p>#Flutter #Dart #OpenSource #OfflineFirst #CRDT #MobileDevelopment #SoftwareEngineering #DistributedSystems</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4be38cd7cc47" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Algorithm Was the Easy Part]]></title>
            <link>https://medium.com/@sparxs.818/the-algorithm-was-the-easy-part-cb35aea616fe?source=rss-bd1fc36752cf------2</link>
            <guid isPermaLink="false">https://medium.com/p/cb35aea616fe</guid>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[biometrics]]></category>
            <category><![CDATA[mobile-engineering]]></category>
            <category><![CDATA[digital-health-technology]]></category>
            <category><![CDATA[digital-health]]></category>
            <dc:creator><![CDATA[Usman Kulaha]]></dc:creator>
            <pubDate>Wed, 29 Jul 2026 10:58:01 GMT</pubDate>
            <atom:updated>2026-07-29T11:00:45.680Z</atom:updated>
            <content:encoded><![CDATA[<p><em>The months a fingerprint scanner trailed our biometric feature — and what it taught me about hardware integration.</em></p><h3>Why we needed biometrics at all</h3><p>The problem was duplicates.</p><p>In a longitudinal HIV program, a patient may return to a facility over years — for ART refills, viral load monitoring, follow-up. Continuity of that record is the entire point. But patient identification in practice leans on names, dates of birth, and card numbers, and all three are fragile. Names get transliterated differently by different clerks. Dates of birth get estimated. Cards get lost and reissued.</p><p>So the same person ends up in the system two or three times, and their treatment history is split across the copies. From a clinical standpoint the clinician sees a partial picture. From a Strategic Information standpoint the indicators are quietly wrong.</p><p>Fingerprints looked like the clean answer. Biological, unique, doesn’t depend on spelling.</p><p>We integrated SecuGen scanners into patient registration and the patient profile in late 2025. I scoped it as a few weeks of work. The matching part was. The connection to the hardware kept resurfacing for months afterward — never as a full-time fire, always as the thing I came back to whenever a new device or a new failure made it the priority again.</p><h3>What I thought the hard part would be</h3><p>Matching. Extracting a template from a captured image, comparing it against stored templates, tuning the threshold so you don’t get false matches on one end or frustrated staff re-scanning four times on the other.</p><p>This turned out to be the settled part of the problem. The matching library was mature. The interesting design questions — batch matching against a growing local template store, keeping it fast enough to run on a mid-range Android device offline — were real engineering problems, but they were <em>tractable</em> engineering problems. I could reason about them, test them, and know when they were done.</p><h3>What the hard part actually was</h3><p>Everything between the app and the physical sensor.</p><p><strong>One model, many devices.</strong> The same scanner family behaves differently depending on the phone or tablet it’s plugged into. Connection setup that was instant on one device would hang on another; a sequence that worked reliably on my desk would fail on hardware I’d never seen. Code that assumed a single “is the scanner available?” boolean was wrong from the start, and the wrongness only surfaced on the devices I didn’t have in front of me.</p><p><strong>Errors as bare integers.</strong> A driver would fail and hand back a number. Not a message — a number. One of them, [error 6], cost me [X] days. It eventually meant that a previous capture session hadn’t been released, so the device refused to open a new one. The fix was small. The diagnosis was not, because nothing in the failure pointed at session lifecycle. It just said 6.</p><p><strong>State drift.</strong> The app’s model of the scanner and the scanner’s actual condition would separate over time — most reliably after the screen slept, the app backgrounded, or a user walked away mid-capture and came back. The scanner was fine. The app thought it was mid-session. Recovering from that gracefully, instead of forcing staff to kill the app, turned out to be a meaningful chunk of the work.</p><p><strong>Recapture, because fingers are not stable.</strong> This is the one I’d emphasize to anyone building this. In a clinic serving patients who do manual labor, fingerprint quality varies enormously — worn ridges, dust, damp, injuries. A template captured on a good day may not match on a bad one. So you need a recapture workflow: a way for staff to update a patient’s stored biometric when the old one stops matching, without that becoming a hole someone can use to attach the wrong record to the wrong person. Designing that safely is a policy question wearing an engineering costume.</p><p>We field-validated the recapture flow at a facility in Lagos in May 2026, and the field is where you find out whether it’s actually usable — not whether it works, but whether a records officer with a queue of twelve people can do it in the time she has.</p><h3>What I’d do differently</h3><p><strong>Get every device combination in the room on day one.</strong> My commit history is a long trail of fixes for combinations I discovered late. The cost of buying or borrowing the awkward devices up front is trivially small compared to the cost of finding out in the field.</p><p><strong>Treat the connection layer as a first-class abstraction.</strong> I let assumptions from the devices I owned leak into logic that later had to serve devices I didn’t. A deliberate interface, written before I thought I needed it, would have saved me weeks of chasing failures that only appeared on unfamiliar hardware.</p><p><strong>Build the diagnostic surface early.</strong> For a long time, a failure in the field reached me as “the fingerprint thing isn’t working.” Nothing more. A visible scanner-state indicator and a local, exportable log would have shortened almost every one of those loops.</p><p><strong>Assume recapture from the start.</strong> I treated it as an edge case. It is not an edge case. It’s a core workflow, and it needed to be designed with as much care as first capture.</p><h3>The takeaway</h3><p>There’s a version of this post that says “hardware is hard,” and that’s true but useless. The more specific version is this:</p><p><strong>Software-to-software integration fails loudly and reproducibly. Software-to-hardware integration fails quietly, intermittently, and only in the field.</strong> Your test suite can’t cover a scanner that’s been in a bag on a motorcycle since Tuesday. So the effort shifts from <em>proving it works</em> to <em>making failure visible, recoverable, and diagnosable from a distance.</em></p><p>If I were scoping this again, I’d still give the matching algorithm a week — but I’d tell whoever was planning the roadmap that the hardware integration would keep reopening for a while, not because it’s endless work, but because each new device in the field gets a vote.</p><p><em>I work on offline-first digital health software in Nigeria. If you’re integrating biometric hardware in the field — or you’ve fought a driver that only speaks in integers — I’d like to hear how it went.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cb35aea616fe" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What Two Years of Building an Offline-First EMR Taught Me About Constraints]]></title>
            <link>https://medium.com/@sparxs.818/what-two-years-of-building-an-offline-first-emr-taught-me-about-constraints-e8d2a1288dbf?source=rss-bd1fc36752cf------2</link>
            <guid isPermaLink="false">https://medium.com/p/e8d2a1288dbf</guid>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[global-health]]></category>
            <category><![CDATA[digital-health]]></category>
            <category><![CDATA[offline-first]]></category>
            <category><![CDATA[africa-health-care]]></category>
            <dc:creator><![CDATA[Usman Kulaha]]></dc:creator>
            <pubDate>Tue, 21 Jul 2026 08:53:52 GMT</pubDate>
            <atom:updated>2026-07-29T11:04:00.697Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Notes from building ViVA Mobile — a Flutter EMR for HIV service delivery in Nigeria.</em></p><h3>The problem is not the software. It’s the assumption underneath it.</h3><p>Most electronic medical record systems are built on a quiet assumption: the network is there. Not always fast, not always reliable, but <em>there</em>. Everything downstream of that assumption — thin clients, live queries, session tokens, server-side validation — is a bet on connectivity.</p><p>In a lot of the world, that bet loses several times a week.</p><p>I lead mobile engineering for ViVA Mobile, an EMR supporting HIV service delivery — HTS, ART, PrEP, PEP, PMTCT, EID — across treatment facilities in Nigeria, including military health facilities. When I started on it in mid-2024, the requirement I kept coming back to wasn’t a feature. It was a sentence: <em>the clinic must not stop when the internet does.</em></p><p>That single constraint reshaped nearly every technical decision that followed.</p><h3>Offline-first is an architecture, not a feature flag</h3><p>The distinction matters more than it sounds. “Offline support” usually means: cache some things, queue some writes, degrade gracefully. Offline-<em>first</em> means you invert the default. The local database is the source of truth for the device. Every clinical form, every vital sign, every lab result is committed locally the moment it’s captured. Synchronization is a separate, asynchronous concern that happens when the world cooperates.</p><p>In practice that meant Flutter with a local SQLite store (drift), Clean Architecture, BLoC for state, and every record carrying its own sync-state flags. A clinician documenting an ART follow-up visit during an outage has exactly the same experience as one documenting it on a good day. The only difference is a small badge showing what hasn&#39;t reached the server yet.</p><p>The payoff is not just convenience. It’s traceability. Because every record created offline carries a local timestamp and a sync state, the Strategic Information team can reconstruct, after the fact, what services were actually delivered during the hours the facility was dark. Paper can’t do that.</p><h3>The hard parts were never where I expected</h3><p><strong>Fingerprint scanners.</strong> We added biometric patient identification in late 2025 to attack a specific problem: duplicate records and patient misidentification. I assumed the matching algorithm would be the challenge. It wasn’t. The challenge was hardware — scanners connecting over USB on one device, drivers reporting cryptic error codes, connection state drifting out of sync with what the app believed. Months of my commit history are, honestly, one long argument with a fingerprint reader.</p><p>The lesson generalizes: when your software touches physical hardware in the field, budget for the hardware, not the algorithm.</p><p><strong>Two devices in the same room.</strong> By early 2026 we had solved “device works without internet.” We had not solved “two devices in the same facility can’t see each other’s work without internet.” A registration desk and a consultation room could each be perfectly functional and completely out of step.</p><p>So we built LAN sync: peer-to-peer synchronization over the facility’s local network. mDNS for device discovery, a small embedded server for transfer, CRDTs with hybrid logical clocks so two devices editing concurrently converge without a central arbiter, X25519 key exchange and AES-256-GCM so nothing moves in the clear, and an explicit device-approval step so only trusted peers exchange data.</p><p>In May 2026 I took it to a facility in Lagos and watched it work with the router unplugged from the internet. A tablet and a phone, reconciling patient state between themselves. That was the moment the mental model clicked into place for me: <strong>resilience isn’t a feature, it’s a stack of independent layers.</strong> Local storage handles total isolation. LAN sync handles a working local network with no internet. Central sync handles full connectivity. Each layer degrades into the one below it.</p><h3>What I got wrong</h3><p>Three things, plainly:</p><p><strong>I underestimated how much hardening a sync feature needs after it ships.</strong> LAN sync shipped and then took months of reliability fixes — discovery failures, UI states that never appeared, edge cases in transfer. Distributed systems in a hospital corridor behave differently than distributed systems on my desk.</p><p><strong>I didn’t separate environments early enough.</strong> We eventually added an explicit instance selector — central, hybrid, training — because the risk of training data mixing with real clinical data is not hypothetical. That should have existed on day one.</p><p><strong>We still don’t have the numbers.</strong> This is the honest one. I can show you a coherent architecture, a commit history, a field validation. I cannot yet show you a measured reduction in duplicate records, or a sync success rate, or a usability score from the nurses and records officers who use it daily. The architecture <em>anticipates</em> impact. Proving impact is a different discipline, and it’s the work I’m prioritizing next: instrumenting the app for basic metrics and running a structured usability evaluation.</p><p>If you build health software, resist the pull to describe intent as outcome. They’re not the same, and the people funding and deploying your work can tell the difference.</p><h3>Where it’s going</h3><p>The current thread is device form factor. Phones and tablets are excellent at the point of care and awkward at a fixed records desk where someone types all day. So there’s now an adaptive landscape shell in development aimed at Chromebooks — same offline-first core, same local database, same LAN sync, just an interface that respects a keyboard and a larger screen. It’s not merged into production yet, and I’d rather say that plainly than imply otherwise.</p><p>The bigger idea is that a single offline-first data layer should be able to serve a phone in an outreach vehicle, a tablet in a consultation room, and a Chromebook at a registration desk, without forking the clinical workflow three ways.</p><h3>The takeaway</h3><p>Building under a hard constraint — <em>this must work with no network</em> — was more clarifying than any amount of feature planning. It removed whole categories of design options, and what remained was mostly correct.</p><p>If you’re building for environments where infrastructure is a variable rather than a given, my honest advice is: pick your one non-negotiable constraint, state it as a sentence, and let it delete things for you.</p><p><em>I’m a senior mobile engineer working on digital health in Nigeria. If you’re building offline-first, working with biometric hardware in the field, or wrestling with CRDTs in production, I’d genuinely like to compare notes.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e8d2a1288dbf" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Part 1: Engineering Digital Health in Africa]]></title>
            <link>https://medium.com/@sparxs.818/part-1-engineering-digital-health-in-africa-d2f9324a6735?source=rss-bd1fc36752cf------2</link>
            <guid isPermaLink="false">https://medium.com/p/d2f9324a6735</guid>
            <category><![CDATA[digital-health]]></category>
            <category><![CDATA[africa]]></category>
            <category><![CDATA[healthcare]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[emr]]></category>
            <dc:creator><![CDATA[Usman Kulaha]]></dc:creator>
            <pubDate>Thu, 04 Dec 2025 14:08:50 GMT</pubDate>
            <atom:updated>2025-12-04T14:08:50.351Z</atom:updated>
            <content:encoded><![CDATA[<h3>Engineering Digital Health in Africa</h3><h4>A 6-part series based on real lessons.</h4><h3>Part 1: The State of EMR Mobile Apps in Africa</h3><p>The adoption of Electronic Medical Records (EMR) across Africa is growing steadily, but mobile EMR apps face unique challenges that require thoughtful solutions. From connectivity issues to real clinic workflow complexities, the mobile-first approach is not just convenient — it’s essential.</p><p><strong>Why Offline-First Matters</strong></p><p>In many parts of Africa, healthcare facilities operate in areas with inconsistent internet connectivity. Expecting EMR apps to rely solely on cloud access can lead to incomplete patient records, delayed updates, and ultimately, compromised care. Offline-first apps address this by storing data locally on the device and synchronizing with central servers when connectivity is available. This ensures that clinicians can access and update patient information in real-time, regardless of network conditions.</p><p><strong>Connectivity Challenges</strong></p><p>Even in urban centers, mobile networks can be unreliable. Rural clinics often face prolonged outages, limited bandwidth, or intermittent connections. For EMR apps, these connectivity challenges mean that offline support isn’t a luxury — it’s a necessity. Applications need to handle local data caching, conflict resolution during syncs, and minimal bandwidth usage to remain effective in these environments.</p><p><strong>Real Clinic Workflow Issues</strong></p><p>African clinics often operate under unique conditions: high patient volumes, resource constraints, and diverse workflows that are not always standardized. EMR apps must adapt to these realities rather than enforce rigid procedures. Features like customizable forms, offline reporting, and intuitive navigation allow healthcare workers to maintain efficiency while accurately capturing patient data. A mobile app that mirrors real clinic workflow reduces frustration, increases adoption, and ultimately improves patient outcomes.</p><p><strong>Why Flutter is Ideal for EMR Apps</strong></p><p>Flutter, Google’s cross-platform framework, has emerged as a strong choice for building EMR mobile applications. Its advantages include:</p><p>•	Cross-platform development: One codebase works on both Android and iOS, saving time and reducing maintenance costs.</p><p>•	Performance: Flutter’s native-like performance ensures smooth operation, even on lower-end devices common in African healthcare settings.</p><p>•	Customizable UI: The framework allows developers to design intuitive and responsive interfaces that adapt to various workflows.</p><p>•	Offline-first capabilities: Flutter can easily integrate with local databases like SQLite or Hive, making offline-first functionality straightforward.</p><p>By leveraging Flutter, developers can deliver EMR apps that are robust, efficient, and truly tailored to the needs of African healthcare providers.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d2f9324a6735" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Simplifying Flutter UI Styling with Extension Methods]]></title>
            <link>https://medium.com/@sparxs.818/simplifying-flutter-ui-styling-with-extension-methods-198431e3211b?source=rss-bd1fc36752cf------2</link>
            <guid isPermaLink="false">https://medium.com/p/198431e3211b</guid>
            <category><![CDATA[code-reusability]]></category>
            <category><![CDATA[flutter-ui]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[extension-method]]></category>
            <category><![CDATA[readability]]></category>
            <dc:creator><![CDATA[Usman Kulaha]]></dc:creator>
            <pubDate>Tue, 09 Apr 2024 11:54:39 GMT</pubDate>
            <atom:updated>2024-04-09T11:54:39.405Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/768/1*utrLzXkjR2AVostWRE4XKQ.png" /></figure><p><strong>Introduction:</strong></p><p>Flutter, a popular framework for building cross-platform mobile applications, offers powerful UI customization capabilities. However, crafting elegant and maintainable UI code can sometimes be challenging, especially when dealing with repetitive styling tasks. In this article, we’ll explore how to simplify UI styling in Flutter using extension methods, compare the traditional approach with the extension method approach, demonstrate how to use these extensions, and discuss the advantages they offer.</p><h3><strong>Traditional Approach:</strong></h3><p>In the traditional approach to styling Flutter UI components like Column and Row, developers often find themselves repeating similar styling code across multiple parts of their application. For instance, applying padding, margins, background colors, borders, and other common styling properties to containers containing rows or columns of widgets can lead to code duplication and decreased readability.</p><p>Example using Traditional Approach:</p><pre>class TraditionalStylingExample extends StatelessWidget {<br>  @override<br>  Widget build(BuildContext context) {<br>    return MaterialApp(<br>      home: Scaffold(<br>        appBar: AppBar(<br>          title: Text(&#39;Traditional Styling Example&#39;),<br>        ),<br>        body: Container(<br>          padding: EdgeInsets.all(20.0),<br>          margin: EdgeInsets.all(10.0),<br>          decoration: BoxDecoration(<br>            color: Colors.blue,<br>            borderRadius: BorderRadius.circular(10.0),<br>            border: Border.all(<br>              color: Colors.black,<br>              width: 2.0,<br>            ),<br>          ),<br>          child: Column(<br>            children: [<br>              Text(<br>                &#39;Hello&#39;,<br>                style: TextStyle(fontSize: 20.0),<br>              ),<br>              SizedBox(height: 10.0),<br>              Text(<br>                &#39;World&#39;,<br>                style: TextStyle(fontSize: 20.0),<br>              ),<br>            ],<br>          ),<br>        ),<br>      ),<br>    );<br>  }<br>}<br><br>class MyApp extends StatelessWidget {<br>  @override<br>  Widget build(BuildContext context) {<br>    return MaterialApp(<br>      home: TraditionalStylingExample(),<br>    );<br>  }<br>}</pre><p>In this traditional approach:</p><ol><li>We define a TraditionalStylingExample widget that builds a basic UI structure using traditional styling methods.</li><li>Styling properties such as padding, margin, background color, border radius, border width, and border color are applied directly to the Container.</li><li>Text widgets are placed inside the Column, and their styles are defined individually.</li></ol><p>While this method achieves the desired styling, it can lead to code duplication if similar styling needs to be applied to multiple parts of the application. Additionally, the code may become less readable and more prone to errors as the UI complexity increases.</p><h3><strong>Extension Method Approach:</strong></h3><p>To address these challenges, we can leverage extension methods in Dart, the programming language used in Flutter development. Extension methods allow us to add new functionality to existing classes without modifying their source code. By creating extensions for Flutter’s Column and Row widgets, we can encapsulate common styling logic, making our code more concise, reusable, and easier to maintain.</p><p><strong>Implementation:</strong></p><p>We define extension methods for Column and Row widgets, which wrap them with a styled container. These extension methods accept parameters such as padding, margin, background color, border radius, border width, border color, width, and height, allowing for flexible customization.</p><p>Example Usage:</p><pre>extension ColumnExtension on Column {<br>  Widget wrapWithStyle({<br>    double padding = 10.0,<br>    double margin = 8.0,<br>    double? width,<br>    double? height,<br>    Color bgColor = Colors.white,<br>    double borderRadius = 0.0,<br>    double borderWidth = 0.0,<br>    Color borderColor = Colors.transparent,<br>  }) {<br>    return Container(<br>      width: width,<br>      height: height,<br>      padding: EdgeInsets.all(padding),<br>      margin: EdgeInsets.all(margin),<br>      decoration: BoxDecoration(<br>        color: bgColor,<br>        borderRadius: BorderRadius.circular(borderRadius),<br>        border: Border.all(<br>          color: borderColor,<br>          width: borderWidth,<br>        ),<br>      ),<br>      child: this,<br>    );<br>  }<br>}<br><br>void MyApp() {<br>  return MaterialApp(<br>    home: Scaffold(<br>      appBar: AppBar(<br>        title: Text(&#39;Flutter Extension Methods&#39;),<br>      ),<br>      body: Column(<br>        children: [<br>          Text(&#39;Hello&#39;),<br>          Text(&#39;World&#39;),<br>        ],<br>      ).wrapWithStyle(<br>        padding: 20.0,<br>        margin: 10.0,<br>        bgColor: Colors.blue,<br>        borderRadius: 10.0,<br>        borderWidth: 2.0,<br>        borderColor: Colors.black,<br>      ),<br>    ),<br>  );<br>}</pre><p><strong>Advantages of Extension Methods:</strong></p><ol><li>Encapsulation: Extension methods encapsulate common styling logic, promoting code reusability and reducing redundancy.</li><li>Readability: By abstracting styling details into extension methods, the main UI code becomes more readable and focused on the widget structure.</li><li>Flexibility: Extension methods accept customizable parameters, allowing developers to tailor styling according to specific requirements.</li><li>Maintenance: Centralizing styling logic in extension methods simplifies maintenance and updates, as changes can be made in one place.</li></ol><h3><strong>Conclusion:</strong></h3><p>In this article, we’ve explored how extension methods can simplify Flutter UI styling by encapsulating common styling logic for Column and Row widgets. By adopting extension methods, developers can streamline their UI code, enhance readability, and improve maintainability. Incorporating extension methods into Flutter projects can lead to more efficient development workflows and ultimately better user experiences.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=198431e3211b" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>