<?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 Asif Ali Sheikh on Medium]]></title>
        <description><![CDATA[Stories by Asif Ali Sheikh on Medium]]></description>
        <link>https://medium.com/@aasifalee.114?source=rss-ad7354b8f267------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*ZyhurPtGEmS91OlAWIVfNQ.png</url>
            <title>Stories by Asif Ali Sheikh on Medium</title>
            <link>https://medium.com/@aasifalee.114?source=rss-ad7354b8f267------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 17 Nov 2026 01:23:22 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@aasifalee.114/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 SDK, Demystified: Build One from Scratch]]></title>
            <link>https://medium.com/@aasifalee.114/flutter-sdk-demystified-build-one-from-scratch-0beae312f9dd?source=rss-ad7354b8f267------2</link>
            <guid isPermaLink="false">https://medium.com/p/0beae312f9dd</guid>
            <category><![CDATA[android-sdk]]></category>
            <category><![CDATA[flutter-sdk]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[sdk]]></category>
            <category><![CDATA[flutter-package]]></category>
            <dc:creator><![CDATA[Asif Ali Sheikh]]></dc:creator>
            <pubDate>Mon, 21 Sep 2026 06:46:31 GMT</pubDate>
            <atom:updated>2026-09-21T06:46:31.000Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tFkq6v7VuhXr19O4oqb7DQ.png" /><figcaption>Flutter makes it surprisingly easy to build reusable packages.</figcaption></figure><p>A few Dart files, a pubspec.yaml, and you already have something another application can depend on. But there is a big difference between <strong>a reusable Flutter package</strong> and a <strong>well-designed SDK</strong>. When you’re building an application, you control almost everything:</p><ul><li>The application’s architecture</li><li>The dependencies</li><li>The navigation</li><li>The state management</li><li>The platform configuration</li><li>The lifecycle</li><li>The release schedule</li></ul><p>An SDK is different.</p><p>Your SDK runs inside <strong>someone else’s application</strong>.</p><p>You don’t know whether they use Bloc, Riverpod, Provider, GetX, or no state-management framework at all. You don’t know how their navigation works. You don’t control their dependency versions. You don’t control how they structure their UI.</p><p>And yet, your SDK needs to work reliably inside that environment. That’s what makes SDK development interesting.</p><p>In this article, we’ll build a fictional Flutter SDK called <strong>Beacon</strong> and walk through the important decisions involved in designing a production-quality SDK.</p><p>We’ll cover:</p><ul><li>SDK architecture</li><li>Package structure</li><li>Public API design</li><li>Internal implementation</li><li>Configuration</li><li>Async operations</li><li>Error handling</li><li>Models</li><li>Platform-specific functionality</li><li>UI components</li><li>Customisation</li><li>Security</li><li>Dependency management</li><li>Testing</li><li>Example applications</li><li>Compatibility</li><li>Documentation</li><li>Backward compatibility</li><li>Common mistakes</li></ul><p>The goal isn’t simply to make the code work.</p><p>The goal is to build an SDK that another developer can integrate without needing to understand how you built it.</p><h3>1. What Is an SDK?</h3><p>SDK stands for <strong>Software Development Kit</strong>.</p><p>In simple terms, an SDK is a collection of tools and APIs that allows another developer to integrate a particular capability into their application.</p><p>For example, an SDK could provide:</p><p>Authentication, Analytics ,Maps, Messaging, Identity verification, Device functionality, Networking, Hardware integration, Payments etc.</p><p>An SDK usually provides more than a single reusable function.</p><p>It may include:</p><pre>SDK<br>├── Public API<br>├── Configuration<br>├── Business logic<br>├── Network layer<br>├── Data models<br>├── Error handling<br>├── UI components<br>├── Platform integrations<br>└── Documentation</pre><p>The consuming application shouldn’t need to understand all of these internal pieces.</p><p>Ideally, the developer sees something simple like:</p><pre>final client = BeaconClient(<br>  BeaconConfig(<br>    apiKey: &#39;demo-key&#39;,<br>  ),<br>);</pre><pre>final result = await client.performAction(<br>  payload: &#39;hello&#39;,<br>);</pre><p>Everything else happens behind the SDK boundary.</p><h3>2. SDK vs Library vs Package</h3><p>These terms are often used interchangeably, but they’re useful to distinguish.</p><h3>Package</h3><p>A <strong>package</strong> is a unit of Dart code distribution.</p><p>For example:</p><pre>dependencies:<br>  beacon: ^1.0.0</pre><p>A package can be small or extremely large.</p><h3>Library</h3><p>A library is reusable functionality focused on a particular problem.</p><p>Examples:</p><ul><li>HTTP client</li><li>Date formatting</li><li>JSON parsing</li><li>Image processing</li></ul><h3>SDK</h3><p>An SDK usually provides a broader integration experience.</p><p>It may contain:</p><ul><li>API</li><li>Configuratio</li><li>Business logic</li><li>Models</li><li>UI</li><li>Platform integration</li><li>Error handling</li><li>Documentation</li></ul><p>The boundaries aren’t strict.</p><p>A Flutter SDK can simply be a Flutter package that provides a complete integration experience.</p><h3>3. When Should You Build a Flutter SDK?</h3><p>Not every piece of reusable code needs to become an SDK.</p><p>An SDK makes sense when the same functionality needs to be integrated into multiple applications or teams.</p><p>For example, imagine five applications all need the same authentication flow.</p><p>Without an SDK:</p><pre>Application A<br>    └── Authentication logic</pre><pre>Application B<br>    └── Authentication logic</pre><pre>Application C<br>    └── Authentication logic</pre><pre>Application D<br>    └── Authentication logic</pre><p>Now every application needs to maintain its own implementation.</p><p>With an SDK:</p><pre>┌───────────────┐<br>              │ Authentication│<br>              │      SDK      │<br>              └───────┬───────┘<br>                      │<br>          ┌───────────┼───────────┐<br>          ↓           ↓           ↓<br>       App A        App B        App C</pre><p>The implementation can evolve inside the SDK while applications interact with a stable API.</p><p>An SDK is especially useful when:</p><ul><li>Multiple applications need the same capability.</li><li>Different teams need the same integration.</li><li>The functionality is complex.</li><li>The implementation contains platform-specific code.</li><li>You want to hide implementation details.</li><li>You want a consistent developer experience.</li></ul><h3>4. The Most Important Difference Between an App and an SDK</h3><p>When developing an application, you can make decisions like:</p><blockquote><em>“Our entire application uses Riverpod.”</em></blockquote><p>That’s fine.</p><p>But an SDK shouldn’t normally force its consumers to use Riverpod.</p><p>The same applies to:</p><ul><li>Bloc</li><li>Provider</li><li>GetX</li><li>MobX</li><li>Any particular navigation package</li></ul><p>Your consumer might already have an architecture.</p><p>Your SDK should integrate with it rather than trying to replace it.</p><p>A good SDK generally provides simple primitives:</p><pre>Future<br>Stream<br>Callbacks<br>Plain Dart classes<br>Widgets<br>Exceptions / Result types</pre><p>and lets the host application decide how those pieces fit into its architecture.</p><h3>5. Planning the SDK Architecture</h3><p>Before writing code, define the boundaries.</p><p>A useful high-level architecture is:</p><pre>┌─────────────────────────────┐<br>│        Public API           │<br>│  Classes / Methods / UI     │<br>└──────────────┬──────────────┘<br>               │<br>               ▼<br>┌─────────────────────────────┐<br>│      Domain / Business      │<br>│           Logic             │<br>└──────────────┬──────────────┘<br>               │<br>               ▼<br>┌─────────────────────────────┐<br>│         Data Layer          │<br>│ Network / Serialization     │<br>└──────────────┬──────────────┘<br>               │<br>               ▼<br>┌─────────────────────────────┐<br>│       Platform Layer        │<br>│    Android / iOS APIs       │<br>└─────────────────────────────┘</pre><p>The key idea is that the <strong>public API should be independent of the internal implementation</strong>.</p><p>Suppose your SDK currently uses one HTTP library.</p><p>Later, you decide to replace it with another.</p><p>The consumer shouldn’t have to change:</p><pre>final result = await client.performAction();</pre><p>That is the kind of independence you want.</p><h3>6. Our Example SDK: Beacon</h3><p>Throughout this article, we’ll use a fictional SDK called <strong>Beacon</strong>.</p><p>Beacon will provide a simple operation:</p><pre>Configure SDK<br>      ↓<br>Perform operation<br>      ↓<br>Receive result</pre><p>The example is intentionally generic.</p><p>The same architecture could be used for:</p><ul><li>Payment SDKs</li><li>Authentication SDKs</li><li>Analytics SDKs</li><li>Identity SDKs</li><li>Messaging SDKs</li><li>Device SDKs</li></ul><h3>7. Creating the Flutter Package</h3><p>If your SDK only needs Dart and Flutter functionality, start with a package:</p><pre>flutter create --template=package beacon</pre><p>If you genuinely need native Android and iOS implementations, you can create a plugin:</p><pre>flutter create --template=plugin --platforms=android,ios beacon</pre><p>The distinction is important.</p><h3>Package</h3><p>Use a package when the functionality can be implemented entirely in Dart/Flutter.</p><h3>Plugin</h3><p>Use a plugin when you need native platform implementations.</p><p>Examples include:</p><ul><li>Bluetooth</li><li>Native payment APIs</li><li>Device hardware</li><li>Native authentication</li><li>Existing native SDKs</li><li>Platform-specific security APIs</li></ul><p>Don’t choose a plugin simply because you’re building an SDK.</p><p>Choose it because you need native functionality.</p><h3>8. Organizing the Project</h3><p>A practical SDK might look like this:</p><pre>beacon/<br>│<br>├── lib/<br>│   ├── beacon.dart<br>│   │<br>│   └── src/<br>│       ├── api/<br>│       │   ├── beacon_client.dart<br>│       │   └── beacon_config.dart<br>│       │<br>│       ├── domain/<br>│       │   └── action_orchestrator.dart<br>│       │<br>│       ├── data/<br>│       │   ├── network/<br>│       │   └── models/<br>│       │<br>│       └── platform/<br>│           └── beacon_platform.dart<br>│<br>├── example/<br>├── test/<br>│<br>├── android/<br>├── ios/<br>│<br>├── pubspec.yaml<br>├── README.md<br>├── CHANGELOG.md<br>└── LICENSE</pre><p>The android/ and ios/ folders are relevant when the SDK contains native platform implementations.</p><p>The exact structure doesn’t have to look exactly like this.</p><p>The important thing is that the boundaries are clear.</p><h3>9. Understanding lib/src</h3><p>You’ll often see Flutter and Dart packages organized like this:</p><pre>lib/<br>├── beacon.dart<br>└── src/<br>    ├── beacon_client.dart<br>    ├── network/<br>    └── internal/</pre><p>You might hear that lib/src is &quot;private.&quot;</p><p>That’s not technically accurate.</p><p>Dart doesn’t make lib/src inaccessible to package consumers.</p><p>A consumer could technically write:</p><pre>import &#39;package:beacon/src/beacon_client.dart&#39;;</pre><p>if that file is available under lib.</p><p>So lib/src is a <strong>convention for implementation details</strong>, not an access-control mechanism.</p><p>The important rule is:</p><blockquote><em>Only APIs intentionally exposed through the package’s public entry point should be considered part of the supported SDK API.</em></blockquote><h3>10. Designing the Public API</h3><p>This is one of the most important parts of SDK development.</p><p>Suppose your internal implementation contains:</p><pre>lib/src/<br>├── beacon_client.dart<br>├── network_client.dart<br>├── request_builder.dart<br>├── response_parser.dart<br>├── token_manager.dart<br>└── internal_models.dart</pre><p>You don’t want consumers to depend on all of those classes.</p><p>Instead, create a public entry point:</p><pre>lib/beacon.dart</pre><p>Then explicitly export the supported APIs:</p><pre>export &#39;src/api/beacon_client.dart&#39;;<br>export &#39;src/api/beacon_config.dart&#39;;<br>export &#39;src/data/models/beacon_result.dart&#39;;<br>export &#39;src/data/models/beacon_exception.dart&#39;;</pre><p>The consumer can now simply write:</p><pre>import &#39;package:beacon/beacon.dart&#39;;</pre><p>and doesn’t need to know how Beacon works internally.</p><h3>11. Keep the Public API Small</h3><p>Every public class becomes something you may need to support for a long time.</p><p>Suppose version 1.0.0 exposes:</p><pre>BeaconClient<br>BeaconConfig<br>BeaconResult<br>BeaconException</pre><p>That’s manageable.</p><p>But imagine exposing:</p><pre>NetworkClient<br>RequestBuilder<br>TokenManager<br>ResponseParser<br>CacheManager<br>InternalController<br>InternalRepository</pre><p>Now consumers may start depending on those classes.</p><p>You eventually discover:</p><blockquote><em>“I want to completely rewrite this internal class.”</em></blockquote><p>But you can’t easily do it because somebody may already depend on it.</p><p>That’s why a small public API is valuable.</p><h3>12. Public API Example</h3><p>A clean SDK API could look like:</p><pre>import &#39;package:beacon/beacon.dart&#39;;<br><br>final client = BeaconClient(<br>  BeaconConfig(<br>    apiKey: &#39;demo-key&#39;,<br>  ),<br>);<br>final result = await client.performAction(<br>  payload: &#39;hello&#39;,<br>);<br>print(result.status);</pre><p>The developer shouldn’t need to know:</p><ul><li>Which HTTP library you use.</li><li>How requests are constructed.</li><li>Where tokens are stored.</li><li>How JSON is parsed.</li><li>Whether native code is involved.</li></ul><p>That’s the SDK’s job.</p><h3>13. Configuration</h3><p>SDK configuration should be explicit.</p><p>For example:</p><pre>class BeaconConfig {<br>  BeaconConfig({<br>    required this.apiKey,<br>    this.timeout = const Duration(seconds: 30),<br>  }) {<br>    _validate();<br>  }<br><br>final String apiKey;<br>  final Duration timeout;<br>  void _validate() {<br>    if (apiKey.trim().isEmpty) {<br>      throw ArgumentError.value(<br>        apiKey,<br>        &#39;apiKey&#39;,<br>        &#39;must not be empty&#39;,<br>      );<br>    }<br>    if (timeout &lt;= Duration.zero) {<br>      throw ArgumentError.value(<br>        timeout,<br>        &#39;timeout&#39;,<br>        &#39;must be greater than zero&#39;,<br>      );<br>    }<br>  }<br>}</pre><p>Now invalid configuration is detected when the configuration is created.</p><p>That’s better than allowing an invalid configuration to travel through several layers and fail much later.</p><h3>14. Instance-Based SDKs vs Singletons</h3><p>There are two common approaches.</p><h3>Instance-Based</h3><pre>final client = BeaconClient(<br>  BeaconConfig(<br>    apiKey: &#39;demo-key&#39;,<br>  ),<br>);</pre><p>This approach has several advantages:</p><ul><li>Dependencies are explicit.</li><li>Testing is easier.</li><li>Multiple instances are possible.</li><li>Configuration is easier to reason about.</li><li>Global state is minimized.</li></ul><p>For many SDKs, this is a good default.</p><h3>Singleton</h3><p>Another approach is:</p><pre>Beacon.initialize(<br>  BeaconConfig(<br>    apiKey: &#39;demo-key&#39;,<br>  ),<br>);</pre><p>and later:</p><pre>Beacon.instance.performAction();</pre><p>A singleton can make sense for functionality that genuinely represents one global resource.</p><p>However, global state makes testing and lifecycle management more complicated.</p><p>Use it deliberately rather than simply because it’s convenient.</p><h3>15. Creating a Reusable Widget</h3><p>If your SDK provides UI, widgets should be composable.</p><p>For example:</p><pre>class BeaconActionButton extends StatelessWidget {<br>  const BeaconActionButton({<br>    super.key,<br>    required this.client,<br>    required this.payload,<br>    required this.onResult,<br>    this.onError,<br>  });<br><br>final BeaconClient client;<br>  final String payload;<br>  final ValueChanged&lt;BeaconResult&gt; onResult;<br>  final ValueChanged&lt;BeaconException&gt;? onError;<br>  @override<br>  Widget build(BuildContext context) {<br>    return ElevatedButton(<br>      onPressed: () async {<br>        try {<br>          final result = await client.performAction(<br>            payload: payload,<br>          );<br>          onResult(result);<br>        } on BeaconException catch (error) {<br>          onError?.call(error);<br>        }<br>      },<br>      child: const Text(&#39;Continue&#39;),<br>    );<br>  }<br>}</pre><p>Notice that the widget doesn’t create the SDK client.</p><p>The client is provided to it.</p><p>This is dependency injection.</p><p>It makes the widget:</p><ul><li>Easier to test</li><li>Easier to reuse</li><li>Easier to customize</li><li>Less coupled to SDK lifecycle</li></ul><h3>16. Don’t Control the Host Application</h3><p>An SDK should be careful about controlling application-level behavior.</p><p>For example, avoid making the SDK automatically:</p><pre>Navigate<br>    ↓<br>Show a Snackbar<br>    ↓<br>Change global application state<br>    ↓<br>Redirect the user</pre><p>Instead, return a result.</p><p>For example:</p><pre>final result = await client.performAction();</pre><pre>if (result.status == BeaconStatus.success) {<br>  // The host application decides what happens next.<br>}</pre><p>The consuming application owns its navigation and global state.</p><p>The SDK should provide the information required to make those decisions.</p><h3>17. Async Operations</h3><p>Most SDK operations are asynchronous.</p><p>For a one-time operation:</p><pre>Future&lt;BeaconResult&gt; performAction({<br>  required String payload,<br>});</pre><p>For continuous events:</p><pre>Stream&lt;BeaconProgress&gt; progress();</pre><p>Use the abstraction that matches the behavior.</p><p>Don’t use Stream simply because it looks more flexible.</p><p>Similarly, don’t expose callbacks everywhere if a Future naturally represents the operation.</p><h3>18. Cancellation</h3><p>Long-running operations should consider cancellation.</p><p>Depending on the SDK, cancellation could be implemented using:</p><ul><li>A cancellation object</li><li>A StreamSubscription</li><li>A networking client’s cancellation mechanism</li><li>Lifecycle-aware operations</li></ul><p>For example, a stream naturally provides cancellation:</p><pre>final subscription = client.progress().listen(<br>  (progress) {<br>    print(progress);<br>  },<br>);<br><br>await subscription.cancel();</pre><p>There isn’t a single universal cancellation mechanism in Dart.</p><p>The correct approach depends on the operation and its underlying implementation.</p><h3>19. Error Handling</h3><p>Avoid exposing implementation-specific errors directly.</p><p>For example, don’t make consumers depend on:</p><pre>SocketException<br>HttpException<br>PlatformException</pre><p>as your primary SDK error model. Instead, create SDK-specific errors:</p><pre>sealed class BeaconException implements Exception {<br>  const BeaconException(this.message);<br><br>final String message;<br>  @override<br>  String toString() {<br>    return &#39;BeaconException: $message&#39;;<br>  }<br>}<br>final class BeaconNetworkException<br>    extends BeaconException {<br>  const BeaconNetworkException(super.message);<br>}<br>final class BeaconValidationException<br>    extends BeaconException {<br>  const BeaconValidationException(super.message);<br>}</pre><p>Now you can change the internal networking implementation without changing the public error contract.</p><h3>20. Exceptions vs Result Types</h3><p>There are different ways to model failures.</p><p>One approach is exceptions:</p><pre>try {<br>  final result = await client.performAction(<br>    payload: &#39;hello&#39;,<br>  );<br>} on BeaconNetworkException catch (error) {<br>  print(error.message);<br>}</pre><p>Another approach is an explicit result type:</p><pre>sealed class BeaconResult&lt;T&gt; {<br>  const BeaconResult();<br>}<br><br>final class BeaconSuccess&lt;T&gt; extends BeaconResult&lt;T&gt; {<br>  const BeaconSuccess(this.value);<br>  final T value;<br>}<br>final class BeaconFailure&lt;T&gt; extends BeaconResult&lt;T&gt; {<br>  const BeaconFailure(this.error);<br>  final BeaconException error;<br>}</pre><p>Then:</p><pre>final result = await client.performAction();<br><br>switch (result) {<br>  case BeaconSuccess(:final value):<br>    print(value);<br>  case BeaconFailure(:final error):<br>    print(error.message);<br>}</pre><p>Both approaches can work. The important thing is consistency.</p><h3>21. Models and Serialization</h3><p>SDKs that communicate with APIs normally need serialization.</p><p>For example:</p><pre>class BeaconResult {<br>  const BeaconResult({<br>    required this.status,<br>    required this.referenceId,<br>  });<br><br>factory BeaconResult.fromJson(<br>    Map&lt;String, dynamic&gt; json,<br>  ) {<br>    return BeaconResult(<br>      status: BeaconStatus.values.byName(<br>        json[&#39;status&#39;] as String,<br>      ),<br>      referenceId: json[&#39;reference_id&#39;] as String,<br>    );<br>  }<br>  final BeaconStatus status;<br>  final String referenceId;<br>}</pre><p>For larger projects, code-generation tools such as json_serializable or freezed can reduce repetitive serialization code.</p><h3>22. Separate Network Models From Public Models</h3><p>This is an important SDK design principle.</p><p>Suppose your backend returns:</p><pre>{<br>  &quot;reference_id&quot;: &quot;12345&quot;,<br>  &quot;customer_status&quot;: &quot;ACTIVE&quot;<br>}</pre><p>Your SDK doesn’t necessarily need to expose that exact structure.</p><p>Instead:</p><pre>Backend JSON<br>     ↓<br>Network Model<br>     ↓<br>Mapping<br>     ↓<br>Public SDK Model</pre><p>For example:</p><pre>class BeaconResponseDto {<br>  const BeaconResponseDto({<br>    required this.referenceId,<br>    required this.customerStatus,<br>  });<br><br>final String referenceId;<br>  final String customerStatus;<br>}</pre><p>Then map it:</p><pre>BeaconResult toPublicModel(<br>  BeaconResponseDto response,<br>) {<br>  return BeaconResult(<br>    status: BeaconStatus.success,<br>    referenceId: response.referenceId,<br>  );<br>}</pre><p>This gives you a buffer between backend changes and your public SDK API.</p><h3>23. Platform-Specific Functionality</h3><p>Flutter can handle a huge amount of functionality directly.</p><p>But sometimes you genuinely need native Android or iOS code.</p><p>Examples include:</p><ul><li>Native payment APIs</li><li>Bluetooth</li><li>Hardware APIs</li><li>Native authentication</li><li>Platform-specific security</li><li>Existing native SDKs</li><li>Native operating-system features</li></ul><p>That’s where Flutter’s platform integration mechanisms become important.</p><h3>24. Flutter Platform Channels</h3><p>One common mechanism is a MethodChannel.</p><p>On the Dart side:</p><pre>import &#39;package:flutter/services.dart&#39;;<br><br>class BeaconPlatform {<br>  static const MethodChannel _channel =<br>      MethodChannel(<br>    &#39;com.example.beacon/methods&#39;,<br>  );<br>  Future&lt;String?&gt; getDeviceIdentifier() {<br>    return _channel.invokeMethod&lt;String&gt;(<br>      &#39;getDeviceIdentifier&#39;,<br>    );<br>  }<br>}</pre><p>The native implementation uses the same channel and method name.</p><p>For example, on Android:</p><pre>MethodChannel(<br>    flutterEngine.dartExecutor.binaryMessenger,<br>    &quot;com.example.beacon/methods&quot;<br>).setMethodCallHandler { call, result -&gt;<br><br>when (call.method) {<br>        &quot;getDeviceIdentifier&quot; -&gt; {<br>            result.success(<br>                getDeviceIdentifier()<br>            )<br>        }<br>        else -&gt; {<br>            result.notImplemented()<br>        }<br>    }<br>}</pre><p>The important thing is that the following form a contract:</p><pre>Channel name<br>     +<br>Method name<br>     +<br>Arguments<br>     +<br>Return values<br>     +<br>Error behavior</pre><p>Both Dart and native implementations must agree on that contract.</p><h3>25. Platform Plugin Architecture</h3><p>For a reusable Flutter plugin, it’s useful to think about the architecture as:</p><pre>Public Dart API<br>                    │<br>                    ▼<br>             Platform Interface<br>               /           \<br>              /             \<br>             ▼               ▼<br>       Android Impl       iOS Impl</pre><p>This separates your public API from the platform implementation.</p><p>For larger platform APIs, <strong>Pigeon</strong> can also be used to generate type-safe communication code between Dart and native platforms.</p><p>The choice between manually managed platform channels and generated communication code depends on the complexity of your native API.</p><p>For a small API, a MethodChannel may be enough.</p><p>For a large API with many methods, models, and callbacks, a typed approach can reduce the amount of manually synchronized channel code.</p><h3>26. Native Registration and Lifecycle</h3><p>A reusable Flutter plugin should normally integrate with Flutter’s plugin registration and lifecycle mechanisms.</p><p>This is different from writing platform-channel code directly inside a single application.</p><p>There is a major distinction between:</p><pre>Native code written for one Flutter application</pre><p>and:</p><pre>Native implementation distributed as a reusable Flutter plugin</pre><p>The latter needs to account for:</p><ul><li>Plugin registration</li><li>Activity lifecycle</li><li>iOS lifecycle</li><li>Engine lifecycle</li><li>Multiple Flutter engines where applicable</li><li>Cleanup of native resources</li></ul><p>Don’t assume the lifecycle of the host application is the same as the lifecycle of your SDK object.</p><h3>27. Platform Threading</h3><p>Don’t perform expensive blocking operations directly on the platform/UI thread.</p><p>For example:</p><pre>Platform request<br>      ↓<br>Validate input<br>      ↓<br>Perform expensive work<br>      ↓<br>Return result</pre><p>Expensive work may include:</p><ul><li>Large file operations</li><li>Database operations</li><li>Cryptographic processing</li><li>Heavy computation</li><li>Long-running native operations</li></ul><p>Move expensive work to an appropriate background mechanism for the platform you’re implementing.</p><p>The exact mechanism differs between Android and iOS.</p><p>The important rule is:</p><blockquote><em>An asynchronous call from Dart doesn’t automatically make expensive native work safe to perform on the UI thread.</em></blockquote><h3>28. Handling Platform Errors</h3><p>Platform APIs can fail.</p><p>On the Dart side, you may encounter:</p><pre>try {<br>  final result = await BeaconPlatform()<br>      .getDeviceIdentifier();<br>} on PlatformException catch (error) {<br>  // Convert to an SDK-level error.<br>} on MissingPluginException {<br>  // Native implementation isn&#39;t available.<br>}</pre><p>Your public SDK API should normally translate these low-level errors into the SDK’s own error model.</p><p>Consumers shouldn’t need to understand whether a failure came from:</p><pre>HTTP<br>Android<br>iOS<br>Flutter<br>MethodChannel</pre><p>unless that information is intentionally part of the public contract.</p><h3>29. SDK Customization</h3><p>If your SDK contains UI, customization should be structured.</p><p>Avoid a configuration class with dozens of unrelated fields:</p><pre>BeaconConfig(<br>  primaryColor: ...,<br>  secondaryColor: ...,<br>  buttonColor: ...,<br>  titleColor: ...,<br>  buttonTextColor: ...,<br>  ...<br>);</pre><p>Instead, group related options:</p><pre>class BeaconConfig {<br>  BeaconConfig({<br>    required this.apiKey,<br>    this.appearance = const BeaconAppearance(),<br>  });<br><br>final String apiKey;<br>  final BeaconAppearance appearance;<br>}<br>class BeaconAppearance {<br>  const BeaconAppearance({<br>    this.primaryColor,<br>    this.buttonColor,<br>    this.buttonTextColor,<br>  });<br>  final Color? primaryColor;<br>  final Color? buttonColor;<br>  final Color? buttonTextColor;<br>}</pre><p>Now future customization options can be added without making the main configuration class increasingly difficult to understand.</p><h3>30. Logging and Debugging</h3><p>SDK logging needs to be carefully controlled.</p><p>Avoid scattering:</p><pre>print(...)</pre><p>throughout the SDK.</p><p>Instead, centralize logging.</p><p>For example:</p><pre>enum BeaconLogLevel {<br>  debug,<br>  info,<br>  warning,<br>  error,<br>}<br><br>class BeaconLoggingOptions {<br>  const BeaconLoggingOptions({<br>    this.level = BeaconLogLevel.warning,<br>    this.onLog,<br>  });<br>  final BeaconLogLevel level;<br>  final void Function(<br>    BeaconLogLevel level,<br>    String message,<br>  )? onLog;<br>}</pre><p>An SDK should generally:</p><ul><li>Be quiet by default.</li><li>Allow debugging when needed.</li><li>Avoid flooding the host application’s logs.</li><li>Provide useful errors.</li><li>Never log secrets.</li></ul><h3>31. Security Considerations</h3><p>One of the most important things to understand about mobile SDKs is that the SDK itself is shipped to the user’s device.</p><p>That means you should never assume that a secret embedded in the SDK is actually secret.</p><p>For example:</p><pre>BeaconConfig(<br>  apiKey: &#39;server-secret&#39;,<br>);</pre><p>is not a secure way to distribute a server-side credential.</p><p>A client SDK should only contain credentials that are appropriate for client-side use.</p><p>Also:</p><ul><li>Don’t log authentication tokens.</li><li>Don’t log payment information unnecessarily.</li><li>Don’t store sensitive data without a clear reason.</li><li>Don’t embed server-side secrets.</li><li>Don’t assume obfuscation makes secrets secure.</li><li>Minimize sensitive information handled by the SDK.</li><li>Document what data the SDK collects or transmits.</li></ul><p>Security should be designed according to the actual threat model rather than added as an afterthought.</p><h3>32. Dependency Management</h3><p>Every dependency your SDK uses becomes part of the consuming application’s dependency graph.</p><p>Suppose your SDK depends on:</p><pre>dependencies:<br>  http: ^1.0.0</pre><p>A consuming application might already depend on another package that uses http.</p><p>The dependency graph could look like:</p><pre>Application<br>├── Beacon SDK<br>│   └── http<br>│<br>├── Analytics SDK<br>│   └── http<br>│<br>└── Application dependencies<br>    └── http</pre><p>Dart’s package resolver needs to find a compatible version set for the complete graph.</p><p>This is why SDK dependencies should be chosen carefully.</p><h3>Good SDK dependency practices</h3><ul><li>Add dependencies only when they’re justified.</li><li>Prefer small, focused dependencies.</li><li>Avoid unnecessarily restrictive version constraints.</li><li>Test your SDK with the dependency versions you support.</li><li>Be aware of transitive dependencies.</li><li>Avoid pulling a large framework into the SDK for a small feature.</li></ul><p>Remember:</p><blockquote><em>Your dependency decision becomes someone else’s dependency problem.</em></blockquote><h3>33. Testing the SDK</h3><p>Testing an SDK requires more than testing individual functions.</p><p>A useful testing strategy is:</p><pre>Unit Tests<br>    ↓<br>Widget Tests<br>    ↓<br>Platform Tests<br>    ↓<br>Native Integration Tests<br>    ↓<br>Example Application</pre><p>Each level catches different problems.</p><h3>34. Unit Testing Business Logic</h3><p>Your core business logic should be testable without making real network requests.</p><p>For example:</p><pre>class BeaconClient {<br>  BeaconClient(<br>    BeaconConfig config, {<br>    required BeaconHttpClient httpClient,<br>  })  : _config = config,<br>        _httpClient = httpClient;<br><br>final BeaconConfig _config;<br>  final BeaconHttpClient _httpClient;<br>  Future&lt;BeaconResult&gt; performAction({<br>    required String payload,<br>  }) {<br>    return _httpClient.perform(<br>      payload: payload,<br>    );<br>  }<br>}</pre><p>A fake client can then be injected:</p><pre>class FakeBeaconHttpClient<br>    implements BeaconHttpClient {<br>  FakeBeaconHttpClient(this.result);<br>final BeaconResult result;<br>  @override<br>  Future&lt;BeaconResult&gt; perform({<br>    required String payload,<br>  }) async {<br>    return result;<br>  }<br>}</pre><p>And tested:</p><pre>test(<br>  &#39;performAction returns the HTTP client result&#39;,<br>  () async {<br>    final expected = BeaconResult(<br>      status: BeaconStatus.success,<br>      referenceId: &#39;12345&#39;,<br>    );<br><br>final client = BeaconClient(<br>      BeaconConfig(<br>        apiKey: &#39;test-key&#39;,<br>      ),<br>      httpClient: FakeBeaconHttpClient(<br>        expected,<br>      ),<br>    );<br>    final result = await client.performAction(<br>      payload: &#39;hello&#39;,<br>    );<br>    expect(<br>      result.referenceId,<br>      &#39;12345&#39;,<br>    );<br>  },<br>);</pre><p>Dependency injection makes the test independent of the real network.</p><h3>35. Widget Testing</h3><p>SDK widgets should be tested independently.</p><p>For example:</p><pre>testWidgets(<br>  &#39;BeaconActionButton reports the result&#39;,<br>  (tester) async {<br>    BeaconResult? receivedResult;<br><br>final client = FakeBeaconClient(<br>      BeaconResult(<br>        status: BeaconStatus.success,<br>        referenceId: &#39;12345&#39;,<br>      ),<br>    );<br>    await tester.pumpWidget(<br>      MaterialApp(<br>        home: BeaconActionButton(<br>          client: client,<br>          payload: &#39;hello&#39;,<br>          onResult: (result) {<br>            receivedResult = result;<br>          },<br>        ),<br>      ),<br>    );<br>    await tester.tap(<br>      find.byType(BeaconActionButton),<br>    );<br>    await tester.pumpAndSettle();<br>    expect(<br>      receivedResult,<br>      isNotNull,<br>    );<br>  },<br>);</pre><p>The important part is that the widget receives a fake client rather than creating a real network client.</p><h3>36. Testing Platform Channels</h3><p>Platform-channel behavior can be tested by mocking the platform messaging layer.</p><p>This allows you to verify that the Dart side sends:</p><pre>Correct channel<br>Correct method<br>Correct arguments</pre><p>and handles:</p><pre>Success<br>Error<br>Missing implementation</pre><p>However, mocked platform tests don’t replace native integration tests.</p><p>They won’t necessarily detect:</p><ul><li>Incorrect Android registration</li><li>Incorrect iOS registration</li><li>Native lifecycle problems</li><li>Platform-specific implementation bugs</li><li>Incorrect native argument handling</li></ul><p>If your SDK contains important native functionality, test the actual native implementations too.</p><h3>37. Native Integration Testing</h3><p>For a platform-enabled SDK, the testing pyramid can look like:</p><pre>Example App<br>                  ▲<br>                  │<br>          Native Integration<br>                  ▲<br>                  │<br>        Platform Channel Tests<br>                  ▲<br>                  │<br>             Widget Tests<br>                  ▲<br>                  │<br>              Unit Tests</pre><p>The deeper tests are usually more expensive, so most business logic should still be covered by fast unit tests.</p><p>But the actual platform integration needs real-platform verification.</p><h3>38. The Example Application</h3><p>An example/ application is strongly recommended for an SDK intended for external developers.</p><p>A typical structure is:</p><pre>beacon/<br>├── lib/<br>├── test/<br>│<br>└── example/<br>    ├── lib/<br>    ├── android/<br>    ├── ios/<br>    └── pubspec.yaml</pre><p>The example application should use the SDK the same way a real consumer would:</p><pre>import &#39;package:beacon/beacon.dart&#39;;</pre><p>Avoid importing:</p><pre>import &#39;package:beacon/src/...&#39;;</pre><p>The example should demonstrate:</p><ul><li>Initialization</li><li>Configuration</li><li>Main SDK functionality</li><li>Success handling</li><li>Error handling</li><li>UI integration</li><li>Platform functionality when applicable</li></ul><p>A developer should be able to open the example application and understand how the SDK is supposed to be used.</p><h3>39. Compatibility</h3><p>An SDK should clearly document the environment it supports.</p><p>For example:</p><p>ComponentRequirementFlutterSupported Flutter rangeDartSupported Dart rangeAndroidMinimum API leveliOSMinimum deployment target</p><p>Don’t assume your SDK supports every version supported by Flutter.</p><p>Your dependencies and native implementations may have their own requirements.</p><p>Compatibility should therefore be treated as part of the SDK’s API contract.</p><h3>40. Documentation</h3><p>Good SDK documentation answers one question:</p><blockquote><em>“How do I integrate this without reading the SDK source code?”</em></blockquote><p>At minimum, document:</p><h3>Installation</h3><p>Show how the dependency is added.</p><h3>Initialization</h3><p>Show the minimum configuration.</p><h3>Basic Usage</h3><p>Show the most common use case.</p><h3>Configuration</h3><p>Explain important options.</p><h3>Error Handling</h3><p>Explain what consumers should expect when something fails.</p><h3>Platform Requirements</h3><p>Document Android/iOS requirements when applicable.</p><h3>API Documentation</h3><p>Use Dart documentation comments:</p><pre>/// Performs the primary Beacon operation.<br>///<br>/// Returns a [BeaconResult] when the operation<br>/// completes successfully.<br>Future&lt;BeaconResult&gt; performAction({<br>  required String payload,<br>});</pre><p>Good documentation isn’t an extra feature.</p><p>For an SDK, <strong>documentation is part of the API</strong>.</p><h3>41. Backward Compatibility</h3><p>Once developers integrate your SDK, they may not upgrade immediately.</p><p>You might have:</p><pre>Application A → Beacon 1.0.0<br>Application B → Beacon 1.2.0<br>Application C → Beacon 1.5.0</pre><p>This means you need to think carefully before changing public APIs.</p><p>When possible, add new APIs before removing old ones.</p><p>For example:</p><pre>@Deprecated(&#39;Use performActionV2 instead&#39;)<br>Future&lt;BeaconResult&gt; performAction() {<br>  return performActionV2();<br>}</pre><p>This gives consumers time to migrate.</p><p>Also remember that breaking changes aren’t limited to removing methods.</p><p>These can also be breaking:</p><ul><li>Changing required parameters</li><li>Changing return types</li><li>Changing error behavior</li><li>Changing default configuratio</li><li>Raising minimum Flutter/Dart versions</li><li>Raising Android API requirements</li><li>Raising the iOS deployment target</li><li>Changing lifecycle behavior</li></ul><p>Treat the public API as a long-term contract.</p><h3>42. Common Mistakes When Building Flutter SDKs</h3><h3>Mistake 1: Exporting Everything</h3><p>Don’t make every internal class public.</p><p>Every public class can become a compatibility burden.</p><h3>Mistake 2: Coupling the SDK to a State-Management Framework</h3><p>Don’t force the consumer to install and use your preferred state-management library unless it is genuinely essential to the SDK.</p><h3>Mistake 3: Creating Global State Everywhere</h3><p>Singletons can be useful, but excessive global state makes SDK behavior difficult to test and reason about.</p><h3>Mistake 4: Exposing Internal Errors</h3><p>Don’t make consumers depend directly on:</p><pre>SocketException<br>PlatformException<br>HttpException</pre><p>unless that’s intentionally part of your public API.</p><h3>Mistake 5: Mixing Network Models With Public Models</h3><p>Backend response structures can change.</p><p>Keep the network representation separate from the public SDK representation when appropriate.</p><h3>Mistake 6: Ignoring Native Lifecycle</h3><p>If your SDK contains native code, understand:</p><ul><li>Activity lifecycle</li><li>iOS lifecycle</li><li>Flutter engine lifecycle</li><li>Resource cleanup</li></ul><h3>Mistake 7: Performing Expensive Work on the UI Thread</h3><p>A platform-channel call being asynchronous doesn’t automatically mean the native implementation can perform unlimited work on the UI thread.</p><h3>Mistake 8: Logging Sensitive Information</h3><p>Never casually log:</p><pre>Passwords<br>Tokens<br>API secrets<br>Payment information<br>Personal information</pre><h3>Mistake 9: Having No Example Application</h3><p>The example application is one of the best ways to demonstrate how your SDK should actually be integrated.</p><h3>Mistake 10: Testing Only the Happy Path</h3><p>Test:</p><pre>Success<br>Failure<br>Timeout<br>Invalid configuration<br>Network failure<br>Platform failure<br>Missing native implementation<br>Unexpected response</pre><p>An SDK needs to behave predictably when things go wrong.</p><h3>43. Production-Readiness Checklist</h3><p>Before considering your Flutter SDK ready for consumers, go through this checklist.</p><h3>Public API</h3><ul><li>Public API surface has been reviewed.</li><li>Every exported API is intentional.</li><li>Internal implementation isn’t unnecessarily exported.</li><li>Public APIs have documentation comments.</li><li>Breaking changes have been identified.</li></ul><h3>Architecture</h3><ul><li>Public API is separated from implementation.</li><li>Business logic is testable.</li><li>Networking is abstracted where appropriate.</li><li>Platform-specific code has a clear boundary.</li><li>Native integration is kept as thin as practica.</li></ul><h3>Configuration</h3><ul><li>Configuration is validated early.</li><li>Invalid values produce clear errors.</li><li>Defaults are documented.</li><li>Sensitive credentials aren’t embedded incorrectly.</li></ul><h3>Error Handling</h3><ul><li>SDK exposes a consistent error model.</li><li>Raw platform/network errors aren’t unnecessarily exposed.</li><li>Error messages are useful.</li><li>Failure paths are documented.</li></ul><h3>Dependencies</h3><ul><li>Dependencies are necessary.</li><li>Version constraints are deliberate.</li><li>Dependency conflicts have been considered.</li><li>Supported dependency versions are documented.</li></ul><h3>Testing</h3><ul><li>Unit tests cover core logic.</li><li>Widget tests cover SDK UI.</li><li>Platform-channel behavior is tested.</li><li>Native implementations are tested where appropriate.</li><li>Example application is tested.</li></ul><h3>Documentation</h3><ul><li>README exists.</li><li>Installation instructions are clear.</li><li>Basic integration example works.</li><li>Configuration is documented.</li><li>Platform requirements are documented.</li><li>API documentation is available.</li><li>Important migration notes are documented.</li></ul><h3>Security</h3><ul><li>Server-side secrets aren’t embedded.</li><li>Sensitive information isn’t logged.</li><li>Sensitive data storage has been reviewed.</li><li>Authentication information is handled carefully.</li><li>Network behavior is understood and documented.</li></ul><h3>Conclusion</h3><p>Building a Flutter SDK is not simply about putting reusable Dart code into a package.</p><p>It’s about designing a <strong>contract between your code and another developer’s application</strong>.</p><p>The architecture can be summarized as:</p><pre>Public API<br>                  │<br>                  ▼<br>          Business / Domain<br>                  │<br>                  ▼<br>              Data Layer<br>                  │<br>                  ▼<br>          Platform Integration</pre><p>The consumer should interact with the top.</p><p>Your implementation should live underneath it.</p><p>A simple SDK might look like:</p><pre>final client = BeaconClient(<br>  BeaconConfig(<br>    apiKey: &#39;demo-key&#39;,<br>  ),<br>);</pre><pre>final result = await client.performAction(<br>  payload: &#39;hello&#39;,<br>);</pre><p>Behind those few lines could be:</p><pre>Configuration<br>      ↓<br>Validation<br>      ↓<br>Business Logic<br>      ↓<br>Network Layer<br>      ↓<br>Serialization<br>      ↓<br>Platform Integration<br>      ↓<br>Error Mapping<br>      ↓<br>Public Result</pre><p>The consumer shouldn’t have to understand that entire chain.</p><p>That’s the point of an SDK.</p><p>Keep the public API small.</p><p>Keep implementation details replaceable.</p><p>Keep dependencies under control.</p><p>Design errors deliberately.</p><p>Test both the Dart and native sides when necessary.</p><p>Give developers a clear example to follow.</p><p>Document the contract.</p><p>And most importantly, remember:</p><blockquote><strong><em>Once another developer depends on your SDK, your public API becomes a contract.</em></strong></blockquote><p>Design that contract carefully, because changing your implementation should be easy. Changing your consumer’s code shouldn’t be.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0beae312f9dd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Docker Didn’t Fix My Bugs. It Just Made Them Reproducible Everywhere]]></title>
            <link>https://medium.com/@aasifalee.114/docker-didnt-fix-my-bugs-it-just-made-them-reproducible-everywhere-7a6beac4a8aa?source=rss-ad7354b8f267------2</link>
            <guid isPermaLink="false">https://medium.com/p/7a6beac4a8aa</guid>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[docker-container]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[docker-image]]></category>
            <dc:creator><![CDATA[Asif Ali Sheikh]]></dc:creator>
            <pubDate>Wed, 15 Apr 2026 05:53:10 GMT</pubDate>
            <atom:updated>2026-04-15T05:53:10.784Z</atom:updated>
            <content:encoded><![CDATA[<p>I learned Docker because my application refused to run anywhere except my laptop, like a spoiled child with commitment issues.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*m_wNHPKYmVWnbnn_k5HoaA.png" /><figcaption>but it work on my machine…😒</figcaption></figure><p>Let’s begin with a universal truth in software development:</p><blockquote><em>Nothing works. And if it works, it’s temporary. </em>Now let me introduce you to a very specific flavour of suffering: <em>“</em><strong><em>It works on my machine</em></strong><em>.” </em>Ah yes. The four words that have destroyed more deployments than actual bugs.</blockquote><h3>The Problem (Also Known as Your Fault, Probably)</h3><p>Every application depends on things you don’t think about until they break. A specific language version. A bunch of libraries. Some system-level dependencies you installed at 2 AM and never questioned again.</p><p>On your machine, everything works. Of course it does. You’ve been slowly shaping that environment for weeks — installing things, fixing errors, forgetting what you fixed.</p><p>It’s not a setup anymore. It’s a <em>habitat</em>.</p><p>Then you move your app to a server, expecting it to behave the same way.</p><p>It doesn’t.</p><p>Because the server hasn’t lived your life. It doesn’t have your dependencies, your versions, or your questionable decisions. So naturally, everything falls apart.</p><p>That’s when Docker shows up.</p><h3>Docker (The Box That Pretends to Solve Everything)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bUaEFffFsUdr5LfSw9Qhgg.png" /><figcaption>Docker</figcaption></figure><p>Docker’s big idea is almost suspiciously simple:</p><p>What if you just packaged everything your app needs into one box?</p><p>That’s it. That’s Docker.</p><p>A container is basically an isolated environment where your app runs with all its dependencies included. Instead of relying on the machine being “set up correctly,” you bring your own setup with you.</p><p>Which is both brilliant and slightly insulting.</p><h3>Containers vs Virtual Machines (A Necessary Rant)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nKQ0mCPXnBlOSUvwixn3MQ.png" /></figure><p>Before Docker, people solved this problem using virtual machines. And technically, they worked.</p><p>But a virtual machine is like deciding to carry an entire house just because you need a kitchen. You get a full operating system, its own kernel, and a level of overhead that makes your laptop sound like it’s preparing for takeoff.</p><p>Containers are lighter. They share the host system’s kernel, which means they don’t need to reinvent the entire universe just to run your app.</p><p>So instead of dragging a house around, you’re just carrying your room.</p><p>Still messy. Just more portable.</p><h3>Docker Images (Freezing Your Mistakes in Time)</h3><p>Docker doesn’t magically guess your setup. You have to spell it out.</p><p>That’s where images come in.</p><p>An image is basically a blueprint — a step-by-step description of what your environment should look like. You write it in a Dockerfile, which is just a plain text file where you list instructions one by one.</p><p>So when you write something like:</p><pre># Build stage<br>FROM maven:3.9.9-eclipse-temurin-17 AS builder<br>WORKDIR /app<br>COPY . .<br>RUN mvn clean package -DskipTests<br><br># Run stage<br>FROM eclipse-temurin:17-jdk-jammy<br>WORKDIR /app<br>COPY --from=builder /app/target/*.jar app.jar<br>CMD [&quot;java&quot;, &quot;-jar&quot;, &quot;app.jar&quot;]</pre><p>you’re not just writing commands — you’re describing an entire lifecycle.</p><p>First, you’re saying:<br> “Take my code and build it using Maven. Yes, the whole thing. Yes, it will take time. No, I don’t want to talk about it.”</p><p>Then you’re saying:<br> “Now forget all of that build chaos. Just take the final JAR file and run it using Java.”</p><p>Which is actually pretty smart. You build the app in one environment, then run it in a much cleaner one without dragging Maven and half the internet into production.</p><p>And when it works, it feels elegant.</p><p>Until it doesn’t.</p><p>Because if something breaks, it could be:</p><ul><li>the build step</li><li>the JAR file</li><li>the copy step</li><li>or something deeply personal</li></ul><p>And now you’re staring at a multi-stage Dockerfile wondering which part of your life led to this moment.</p><h3>Containers (Where Things Actually Happen)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HuxZdb3iF81uK_wGRWJ3Dw.png" /><figcaption>image vs container</figcaption></figure><p>An image just sits there looking important. Nothing really happens until you run it.</p><p>The moment you run an image, it becomes a container.</p><p>Now your app is alive — inside its own little world. It has its own filesystem, its own environment, and no awareness of the chaos outside.</p><p>Which is great… until you try to access it.</p><h3>Ports (The Part That Confuses Everyone)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cxdYp9GRFK3oQ6dmRp1YDQ.png" /><figcaption>port:8080</figcaption></figure><p>Your app is running inside a container. Perfect.</p><p>Except you can’t reach it.</p><p>This is where ports come in. Containers are isolated by design, so if your app is listening on a port inside the container, your system doesn’t automatically know about it.</p><p>You have to explicitly map it.</p><p>When you run something like:</p><pre>docker run -p 8080:8080 my-app</pre><p>you’re basically saying, “Take port 5000 inside the container and expose it as port 5000 on my machine.” Once you understand that, it feels obvious. Until it doesn’t.</p><h3>Volumes (Because Losing Data Builds Character, Apparently)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bddakUEOEE5RgC54HkMbPw.png" /><figcaption>volumes</figcaption></figure><p>By default, containers don’t keep anything once they’re gone. You stop it, remove it, and your data disappears with it.</p><p>Which is a bold design choice.</p><p>To fix that, Docker gives you volumes. They store data outside the container, so even if the container dies (and it will), your data survives.</p><p>It’s the closest thing Docker offers to emotional stability.</p><h3>Why Docker Is Actually Useful</h3><p>Here’s the annoying part: despite all the sarcasm, Docker genuinely solves real problems.</p><p>It gives you consistency. The same environment runs everywhere, which means fewer surprises. Not zero surprises — just fewer.</p><p>It isolates your applications, so they don’t interfere with each other like badly designed group projects.</p><p>It makes your app portable. You can move it from your laptop to a server to the cloud without rebuilding everything from scratch.</p><p>And most importantly, it makes environments reproducible. You can recreate the exact same setup again and again — which is incredibly useful when debugging.</p><p>Even if it means you’re reproducing the same mistake repeatedly.</p><h3>The Reality</h3><p>Docker won’t fix your code. It won’t magically improve your architecture. And it definitely won’t make you immune to bugs.</p><p>What it does is remove one major source of chaos: inconsistent environments.</p><p>And that alone is worth it.</p><h3>Final Thoughts (Written Mid-Debug)</h3><p>Docker isn’t magic.</p><p>It’s just a way to package your application and everything it needs into a predictable, portable unit.</p><p>It reduces uncertainty. It standardizes how things run. And it replaces one kind of confusion with a slightly more manageable one.</p><p>Which, in software development, counts as a win.</p><p>So the next time your app breaks, just remember:</p><p>It’s not that it doesn’t work anymore…<br> it’s that it never really worked anywhere else to begin with.</p><p>And if this felt a little too relatable, feel free to:</p><ul><li>drop a clap 👏</li><li>or leave a comment about the most ridiculous bug Docker helped you <em>reproduce perfectly</em></li></ul><p>Misery loves company.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7a6beac4a8aa" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Expo Just Befriended Flutter… and Developers Are Losing Their Minds]]></title>
            <link>https://medium.com/@aasifalee.114/expo-just-befriended-flutter-and-developers-are-losing-their-minds-34739f650047?source=rss-ad7354b8f267------2</link>
            <guid isPermaLink="false">https://medium.com/p/34739f650047</guid>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[devops-for-mobile]]></category>
            <category><![CDATA[expo]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[cicd]]></category>
            <dc:creator><![CDATA[Asif Ali Sheikh]]></dc:creator>
            <pubDate>Mon, 24 Nov 2025 05:43:39 GMT</pubDate>
            <atom:updated>2025-11-24T05:43:39.543Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fVGuNGJ6vpnNtZUK1jdWdQ.png" /><figcaption>Expo befriended flutter</figcaption></figure><p><em>A surprisingly wholesome story about two rivals teaming up</em></p><p>If you’ve been around the mobile-development world long enough, you know that Flutter and Expo have always behaved like those two classmates who sit on opposite ends of the room, pretending they don’t care about each other. Flutter, the studious Google kid with Dart books stacked till the ceiling. Expo, the cool React Native senior who walks around with a wireless keyboard and a smirk.</p><p>And suddenly, out of nowhere, <strong>Expo Launch now supports Flutter</strong>.</p><p>Yes, you read that right. The two kids are working on the same project nowand nobody saw it coming.</p><h3>So… What Exactly Is Expo Launch? (Explained Like Your Chill Professor)</h3><p>Imagine you’re turning in your project. You’ve done all the hard work, written the code, tested everything, and now the difficult part begins:<br> <em>Packaging it, signing it, offering sacrifices to Xcode, praying Google Play accepts your bundle…</em></p><p>Expo Launch is the TA who says, “Relax beta, I’ll submit it for you.”<br> You give it your GitHub repo, and it quietly takes over the entire build and submission process.</p><p>For years, this magic was available only to React Native folks. Flutter students had to struggle with Xcode tantrums and Android keystore mysteries on their own.</p><p>But now? Expo has opened the gates.</p><h3>Flutter Meets Expo — What Does This Really Mean?</h3><p>It means that Flutter developers can now use Expo’s automated world-class infrastructure to build, package, and even submit their apps to the App Store and Play Store. No more juggling Mac machines, signing files, or wondering why your build only fails on Tuesdays.</p><p>Your Flutter project goes in.<br> Expo brews chai, sits down, and handles the tough parts.</p><p>It still can’t turn Flutter into an Expo Go–style system (Flutter is too proudly native for that), but for deployment and CI/CD, this partnership is surprisingly powerful.</p><h3>How It Works (Without Boring You to Sleep)</h3><p>You connect your Flutter GitHub repo to Expo Launch.<br> Expo scans it, nods wisely like Gandalf, and says, “Yes, I understand this project.”<br> Then it sets up the build steps, manages certificates, provisions profiles, and even talks politely to Apple and Google on your behalf.</p><p>You press a button.<br> Expo builds your Android, iOS, and even web versions.<br> Another button — your app is on the store.</p><p>You? You go make maggi.</p><h3>Why This Is Actually a Big Deal</h3><p>Ask any Flutter developer what they fear, and they’ll never say “multithreading” or “animations.”<br> They’ll say “App Store submission.”<br> They’ll say “iOS certificates.”<br> They’ll say “Why does Xcode hate me specifically?”</p><p>Expo Launch stepping in is like a senior arriving just before your viva and whispering the exact answers you need. It brings peace, stability, and slightly reduced blood pressure.</p><h3>But Let’s Be Honest… There Are Limits</h3><p>Flutter is still compiled to native binaries, so don’t expect Expo Go, snack previews, or magical over-the-air JS patching. Expo can’t perform surgery on a compiled binary.</p><p>So while Expo helps Flutter <em>release</em> apps, it doesn’t change <em>how</em> Flutter apps run.</p><p>And that’s fine. Because no one asked Expo to rewrite the physics of how Flutter works. We just wanted easier deployments, and now we have them.</p><h3>Should You Even Care?</h3><p>If you’re an indie dev, a student doing your final-year Flutter app, or a working professional who has screamed at Xcode at least once this month — yes, you should absolutely care.</p><p>If your company has a thousand build flavors, three QA environments, and a DevOps engineer who gets paid specifically to fight CI pipelines — you may still prefer your existing toolchain.</p><p>But for most normal humans?</p><p>Expo Launch makes Flutter’s release process feel <em>human</em> again.</p><h3>The Bigger Picture: Expo Is Growing Up</h3><p>What Expo is doing here is like that moment when a popular senior stops hanging out only with their own group and helps juniors preparing for placements. Expo isn’t just a React Native tool anymore — it’s positioning itself as <em>the</em> universal app-launching service.</p><p>Flutter just happens to be its newest friend.</p><h3>Final Thoughts</h3><p>This integration is good for Flutter, great for indie developers, and hilarious for anyone who enjoyed the silent rivalry between Flutter and React Native communities. Expo entering the Flutter world is a plot twist no one predicted, but everyone is secretly happy about.</p><p>Personally?<br> I’ll grab popcorn and watch what happens next.</p><h3>Conclusion</h3><p>Expo opening its doors to Flutter feels like one of those rare moments in tech where two different worlds shake hands for the benefit of everyone. It doesn’t rewrite how Flutter works, and it doesn’t magically give us Expo Go, but it <em>does</em> make releasing apps far less painful. And honestly, that alone feels like a small miracle.</p><p>If you found this breakdown helpful, or if you’ve tried Expo Launch with a Flutter project yourself, I’d love to hear your experience.<br> <strong>Drop your thoughts in the comments — and if this article gave you even one “aha!” moment, feel free to leave a clap or two.</strong></p><p>Your feedback helps me write better (and funnier) breakdowns next time!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=34739f650047" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Quantum Computing: From Schrödinger’s Cat to Google’s Qubits]]></title>
            <link>https://medium.com/@aasifalee.114/quantum-computing-from-schr%C3%B6dingers-cat-to-google-s-qubits-2446e24f1024?source=rss-ad7354b8f267------2</link>
            <guid isPermaLink="false">https://medium.com/p/2446e24f1024</guid>
            <category><![CDATA[quantum-superposition]]></category>
            <category><![CDATA[quantum-physics]]></category>
            <category><![CDATA[qubit]]></category>
            <category><![CDATA[quantum-computing]]></category>
            <category><![CDATA[entanglement]]></category>
            <dc:creator><![CDATA[Asif Ali Sheikh]]></dc:creator>
            <pubDate>Wed, 24 Sep 2025 09:06:51 GMT</pubDate>
            <atom:updated>2025-09-24T09:06:51.218Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/784/1*sCoEYUSiiRGyLVIUHixvkA.png" /><figcaption>Quantum World</figcaption></figure><p>You’ve probably heard the phrase <em>“quantum leap”</em>. People use it when they want to sound smart in meetings:</p><blockquote>With this feature, our app will make a quantum leap in user engagement!</blockquote><p>Sorry to burst the bubble — a quantum leap is actually the <strong>smallest possible leap in physics</strong>. So unless your app is shrinking itself to atomic size, maybe let’s leave that one in the lab coat crowd.</p><p>But hey, while we’re here, let’s actually talk about <strong>quantum computing </strong>what it is, why everyone from Google to grandma is talking about it, and why Schrödinger’s cat is still the most famous unpaid physics influencer.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/501/1*vKsW000hQ3ZWz240sjfD5Q.png" /><figcaption>classical physics</figcaption></figure><h3>Act 1: Quantum Physics — The Rules Nobody Agreed To</h3><p>Classical physics is nice and cozy:</p><ul><li>You throw a ball, it goes up and comes down.</li><li>Planets orbit the sun like clockwork.</li><li>Coffee falls if you drop it (sadly).</li></ul><p>Then came <strong>quantum physics</strong>, which said:</p><ul><li><em>“Particles can be waves, waves can be particles, and sometimes they’re both at the same time.”</em></li><li><em>“Oh, and they can teleport their state to each other, even across galaxies. No biggie.”</em></li><li><em>“Also, nothing’s real until you measure it. So that chair might not be there until you sit on it.”</em></li></ul><p>Einstein called it <em>“spooky action at a distance.”</em> I call it <strong>the universe trolling us.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/507/1*ecKKxl-XDtsFz4Pe2Fpk3Q.png" /><figcaption>Schrödinger’s Cat</figcaption></figure><h3>Act 2: Schrödinger’s Cat — The Meme That Started It All</h3><p>In 1935, physicist Erwin Schrödinger imagined a cat in a box with a vial of poison triggered by radioactive decay.</p><ul><li>If the atom decays → cat dies.</li><li>If not → cat lives.</li></ul><p>Quantum rules say the atom is in a <em>superposition</em> (both decayed and not decayed). Meaning the poor cat is both <strong>dead and alive at the same time</strong>, at least until you open the box.</p><p>Thus, Schrödinger invented the <strong>first quantum meme</strong>, long before the internet existed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/493/1*KfxFYKFORu2qfTew30gONA.png" /><figcaption>Superposition</figcaption></figure><h3>Act 3: Qubits — Quantum Bits With Commitment Issues</h3><p>Classical computers use <strong>bits</strong>: 0 or 1.<br> Quantum computers use <strong>qubits</strong>, which can be:</p><p><strong>0, 1</strong> or a magical blend of both (superposition).</p><p>Think of a qubit like me deciding what to have for dinner:</p><p><strong>0 = pizza</strong></p><p><strong>1 = burger</strong></p><p>qubit = <em>pizza AND burger simultaneously</em> until UberEats arrives and forces me to choose.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/503/1*XE9unIvDqj-ogklLY5alAg.png" /><figcaption>Entanglement</figcaption></figure><h3>Act 4: Entanglement — Cosmic Group Chats</h3><p>Qubits also do this weird thing called <strong>entanglement</strong>. When two qubits are entangled:</p><ul><li>Measuring one instantly tells you about the other.</li><li>Doesn’t matter if one’s in your laptop and the other’s chilling near a black hole.</li></ul><p>It’s basically the universe’s <strong>worst-kept secret DM channel.</strong></p><h3>Act 5: Why Should You Care?</h3><p>Because quantum computers aren’t just “faster laptops.” They could:</p><ul><li>Crack current internet encryption like peanuts.</li><li>Simulate molecules to invent drugs (goodbye, 10-year pharma trials).</li><li>Optimize traffic, logistics, and even your dating life (though maybe not).</li></ul><p>Of course, right now most quantum computers need giant fridges colder than outer space, and they throw tantrums if you even breathe near them. But hey — so did classical computers in the 1940s.</p><h3>Finale: The Quantum Punchline</h3><p>Quantum computing is basically the universe saying:</p><blockquote>You thought you understood me with your cute little Newton’s laws? Adorable. Here’s a computer that works by <strong>not deciding</strong> until the very last second.</blockquote><p>So the next time someone at work says <em>“quantum leap”</em>, you can smile, sip your coffee, and say:</p><blockquote>Actually, I’m waiting for the quantum computer to calculate if I should care or not.</blockquote><p>Quantum physics may still feel like the universe’s greatest prank, but quantum computing is very real — and it’s coming faster than you think. Whether it excites you, confuses you, or just makes you worry about Schrödinger’s cat, one thing’s certain: the quantum era is unfolding right in front of us.</p><p>If you enjoyed this article:<br> 👉 Give it a <strong>👏 clap </strong><br> 👉 Share it with your fellow curious humans<br> 👉 Drop your thoughts, questions, or favorite quantum memes in the comments.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2446e24f1024" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Parallelism vs Concurrency in Flutter: A Developer’s Guide]]></title>
            <link>https://medium.com/@aasifalee.114/parallelism-vs-concurrency-in-flutter-a-developers-guide-6accc9b4cafc?source=rss-ad7354b8f267------2</link>
            <guid isPermaLink="false">https://medium.com/p/6accc9b4cafc</guid>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[isolates-in-flutter]]></category>
            <category><![CDATA[concurrency]]></category>
            <category><![CDATA[parallelism]]></category>
            <category><![CDATA[asyncawait]]></category>
            <dc:creator><![CDATA[Asif Ali Sheikh]]></dc:creator>
            <pubDate>Sun, 17 Aug 2025 10:30:45 GMT</pubDate>
            <atom:updated>2025-08-17T10:30:45.852Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*q66s2dd-R_wVjmBLeEKV1g.png" /></figure><p>When you start building apps in Flutter, sooner or later you’ll face a situation where your app needs to do <strong>more than one thing at once</strong>. Maybe you’re fetching data from an API while showing a loading spinner, or processing a large file without freezing the UI.</p><p>That’s where two important concepts come in: <strong>Concurrency</strong> and <strong>Parallelism</strong>. Although they sound similar, they solve different problems. Understanding the difference is crucial for writing performant, smooth Flutter apps.</p><h3>🔹 What is Concurrency?</h3><p>Think of <strong>concurrency</strong> as a restaurant kitchen with a single chef. The chef can’t cook multiple dishes at the exact same time, but he can <strong>switch tasks efficiently</strong>:</p><ul><li>Chop veggies</li><li>Put something on the stove</li><li>While it cooks, prepare salad</li><li>Then return to stir the pan</li></ul><p>In programming, <strong>concurrency means structuring your code to handle multiple tasks in progress, without necessarily running them simultaneously.</strong></p><h3>Example in Flutter:</h3><pre>Future&lt;void&gt; fetchData() async {<br>  print(&quot;Fetching user...&quot;);<br>  await Future.delayed(Duration(seconds: 2)); // simulate API<br>  print(&quot;User data received!&quot;);<br>}</pre><pre>Future&lt;void&gt; main() async {<br>  print(&quot;Start&quot;);<br>  await fetchData();<br>  print(&quot;Done&quot;);<br>}</pre><p>Here, while waiting for the API (Future.delayed), Flutter is free to handle UI updates, animations, and user interactions. That’s concurrency.</p><h3>🔹 What is Parallelism?</h3><p>Now imagine the same restaurant with <strong>multiple chefs</strong>. One cooks pasta, another bakes pizza , and a third prepares dessert <strong>at the same time</strong>.</p><p><strong>Parallelism means actually running multiple tasks at the same time using multiple CPU cores.</strong></p><p>In Flutter (Dart), parallelism is achieved using <strong>Isolates</strong>. Unlike async/await, which is still single-threaded, isolates truly run in parallel, because Dart doesn’t share memory between isolates.</p><h3>🔹 Concurrency in Flutter: Futures, async/await, and Streams</h3><p>Flutter apps are <strong>single-threaded by default</strong> (UI thread), but they manage concurrency with:</p><ol><li><strong>Futures</strong> → One-time async results</li></ol><pre>Future&lt;String&gt; getUser() async {  <br> return Future.delayed(Duration(seconds: 2), () =&gt; &quot;John Doe&quot;); <br>}</pre><p><strong>2. async/await</strong> → Cleaner syntax for Futures</p><pre>void fetchUser() async {<br>   String user = await getUser(); <br>  print(user); <br>}</pre><p><strong>3. Streams</strong> → Continuous flow of async data</p><pre>Stream&lt;int&gt; numberStream() async*{<br>   for (int i = 0; i &lt; 5; i++) {  <br>   await Future.delayed(Duration(seconds: 1));  <br>   yield i;   <br>  }<br> }</pre><p>These tools keep the UI responsive even when doing heavy I/O work (network, database, etc.).</p><h3>Parallelism in Flutter: Isolates</h3><p>If you try to do CPU-heavy work (like parsing a 50MB JSON file or image processing) directly on the main isolate, the app will freeze. That’s where <strong>Isolates</strong> come in.</p><h4>Example: Using Isolate</h4><pre>import &#39;dart:isolate&#39;;<br>void heavyTask(SendPort sendPort) {<br>  int sum = 0;<br>  for (int i = 0; i &lt; 1000000000; i++) {<br>    sum += i;<br>  }<br>  sendPort.send(sum);<br>}<br>void main() async {<br>  ReceivePort receivePort = ReceivePort();<br>  await Isolate.spawn(heavyTask, receivePort.sendPort);<br>  receivePort.listen((message) {<br>    print(&quot;Result: $message&quot;);<br>  });<br>}</pre><p>Here, the heavy calculation runs on another isolate, keeping the UI smooth.</p><p>✅ Pro tip: Use the compute function in Flutter for simple parallel work.</p><pre>import &#39;package:flutter/foundation.dart&#39;;<br>int sumNumbers(int n) {<br>  int sum = 0;<br>  for (int i = 0; i &lt; n; i++) sum += i;<br>  return sum;<br>}<br>void main() async {<br>  final result = await compute(sumNumbers, 1000000000);<br>  print(result);<br>}</pre><h3>When to Use What?</h3><ul><li>Use <strong>Concurrency (Futures, async/await, Streams)</strong> for:<br> ✅ API calls<br> ✅ Database reads/writes<br> ✅ User input handling<br> ✅ File I/O</li><li>Use <strong>Parallelism (Isolates)</strong> for:<br> ✅ Heavy JSON parsing<br> ✅ Image processing<br> ✅ Cryptography<br> ✅ Machine learning models</li></ul><h3>📝 Final Thoughts</h3><p>Flutter makes concurrency simple with <strong>async/await</strong> and <strong>streams</strong>, while still giving you control over <strong>parallelism</strong> through <strong>isolates</strong>.</p><p>If your task is <strong>I/O-bound</strong>, stick to concurrency.<br>If it’s <strong>CPU-bound</strong>, offload it to an isolate.</p><p>By knowing when to use <strong>concurrency vs parallelism</strong>, you’ll keep your Flutter apps <strong>smooth, responsive, and performant — even under heavy workloads</strong>.</p><p>💬 What are your experiences with concurrency and parallelism in Flutter? Drop your thoughts in the comments!<br> 👏 If this article helped you, don’t forget to give it a clap (or a few 😉).</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6accc9b4cafc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Debugging the Universe: The Life of Nikola Tesla as Told by Developer on the Edge.]]></title>
            <link>https://medium.com/@aasifalee.114/debugging-the-universe-the-life-of-nikola-tesla-as-told-by-a-burnt-out-developer-ae4dc1814ce9?source=rss-ad7354b8f267------2</link>
            <guid isPermaLink="false">https://medium.com/p/ae4dc1814ce9</guid>
            <category><![CDATA[physics]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[nikola-tesla]]></category>
            <category><![CDATA[tesla]]></category>
            <category><![CDATA[electricity]]></category>
            <dc:creator><![CDATA[Asif Ali Sheikh]]></dc:creator>
            <pubDate>Sun, 03 Aug 2025 10:13:35 GMT</pubDate>
            <atom:updated>2025-08-03T10:20:10.715Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>By: A developer who deeply relates to dying broke while still waiting for someone to fund his side project.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1006/1*aFePMWE_qEaRAbLfHOTF8A.png" /></figure><p>Nikola Tesla is the kind of guy you’d find on GitHub building a self-sustaining weather system in Python while refusing all VC funding because “it’s not ready yet.”</p><p>But beneath the lightning bolts and wireless dreams is a story that every developer knows too well: <strong>brilliant ideas, terrible managers, and a string of jobs that ended with someone else taking the credit.</strong></p><p>Let’s walk through Tesla’s life like it’s a dev career timeline, because, honestly, it was.</p><h3>No Degree? No Problem — Tesla Dropped Out Too</h3><p>Let’s clear this up: <strong>Tesla never finished college</strong>.<br> He enrolled at the Polytechnic Institute in Graz, Austria — and dropped out halfway through.</p><p>Why? His dad died. He burned out. He fell behind on exams.<br> Sound like half the devs you know?</p><p>But that didn’t stop him.</p><p>Tesla kept learning on his own. He read, he experimented, he built — and eventually, he shaped the electrical infrastructure of the modern world.</p><p>If you’re a student who never got to finish college — or someone who took a different path — don’t let anyone tell you you’re less than.<br> Tesla didn’t graduate either. He still changed history.</p><h3>Intern Years (Austria-Hungary): 1856–1884</h3><p>Tesla grew up in modern-day Croatia, where he spent most of his time reverse-engineering the universe. While other kids were chasing balls, Tesla was building mini hydropower plants out of twigs and frogs.</p><p>He studied electrical engineering, but like most devs, <strong>he never actually finished his degree</strong>. He just… kept building stuff anyway. Because why waste time with paperwork when you’re already 30 commits deep?</p><h3>First Job: Edison Company — 1884</h3><p>Tesla moved to the U.S. with nothing but four cents, a letter of recommendation, and probably 60 unfinished inventions in his head. He joined <strong>Thomas Edison</strong>, who was basically running the Microsoft of electricity at the time — closed source, patents locked down, innovation throttled behind enterprise paywalls.</p><p>Tesla showed up like:</p><blockquote><em>“Hey, I can fix your DC motor. Also, AC power is objectively better.”</em></blockquote><p>Edison:</p><blockquote><em>“Cool, fix the motor, and I’ll give you $50,000.”</em></blockquote><p>Tesla fixes it. Edison laughs and says:</p><blockquote><em>“It was a joke.”</em></blockquote><p>🥲 First job lesson: Always get it in writing.</p><p>Tesla quits.</p><h3>Startup Life: Tesla Electric Company — 1887</h3><p>Tesla launched his own startup backed by investors who, shockingly, <em>actually</em> paid him. He developed the <strong>alternating current (AC)</strong> system, which was cleaner, safer, and more efficient than Edison’s DC grid.</p><p>Then came <strong>The Current Wars</strong> — imagine an Flutter vs. Native fight, but with more electrocutions. Edison literally killed animals in public to make AC look dangerous. 🐘💀</p><p>But AC won. It powered the 1893 Chicago World’s Fair and, soon, the entire U.S. grid.</p><p>Tesla thought this was his big break. Spoiler: it wasn’t.</p><h3>GitHub Collab Gone Wrong: Partnership with Westinghouse</h3><p>George Westinghouse backed Tesla and licensed his AC patents. Great! Recognition! Money! Future secure!</p><p>Except… Westinghouse hit financial trouble. To save the company, Tesla <strong>tore up his own royalties contract</strong>, basically saying:</p><blockquote><em>“Don’t worry about the millions you owe me. Just keep the lights on.”</em></blockquote><p>That single contract would’ve made him one of the richest men in the world.</p><p>Lesson: <strong>Don’t be too nice. Especially if you’re holding valuable IP.</strong></p><h3>Peak Dev Energy: Wardenclyffe &amp; Wireless Power (1901)</h3><p>Tesla built a 185-foot tower on Long Island to deliver free wireless electricity across the world. Think: open-source WiFi for energy. He told his funder, J.P. Morgan, it would make money through communications.</p><p>Morgan was like:</p><blockquote><em>“Wait… free electricity? You trying to kill my entire business model?”</em></blockquote><p>Funding: pulled. Tower: abandoned. Tesla: crushed.</p><h3>Legacy Code &amp; Weird Prototypes (1910–1930s)</h3><p>This is the Tesla equivalent of a senior dev who’s gone full wizard in a lab full of old tech and pigeons.</p><ul><li>He created wireless-controlled boats (basically RC cars in the 1800s).</li><li>He designed earthquake machines.</li><li>Claimed to receive signals from Mars (probably just bad logs).</li><li>Tried to develop a “death ray” (definitely not code-reviewed).</li></ul><p>People stopped listening. Journalists treated him like the tech prophet who had lost it. In reality, <strong>he was just 100 years early.</strong></p><h3>End of the Road: Alone, Broke, and Ghosted by History</h3><p>Tesla died in 1943 in a hotel room in New York — alone, in debt, and feeding birds. No mansion. No monument. Just a trunk full of notebooks that the FBI seized <strong>because even in death, they weren’t sure what he was capable of.</strong></p><p>The dude invented wireless communication, robotics, and laid the groundwork for Wi-Fi — and still had to die with an unpaid hotel bill.</p><p>Meanwhile, Edison got all the textbooks and a power company named after him.</p><h3>🌌 Tech Is My World. But Physics? That’s the Rabbit Hole.</h3><p>I’m a tech guy — through and through.<br>But physics? That’s where I lose myself.</p><p>Every time I dive into Tesla’s world — his visions, his math, his madness — I find my brain spinning in awe.</p><p>He didn’t just invent cool things.<br>He tried to understand reality itself.</p><p>That kind of curiosity is what drives me. Overwhelms me. And keeps me building.</p><h3>Final Thoughts from a Fellow Dev</h3><p>Tesla wasn’t just an inventor — he was an idea guy, a relentless builder, and a believer in tech for the people.<br> He had no business sense, trusted the wrong people, and kept working even when the world stopped listening.</p><p>If that doesn’t sound like half the developers on Earth, I don’t know what does.</p><p>And being a dev who vibes hard with physics, I feel this story more than I probably should. There’s something about chasing clean code by day and trying to understand quantum weirdness at night that just… hits different.</p><p>Tesla didn’t separate science and invention — he saw technology as a way to touch the fundamental forces of the universe. And honestly, that mindset is still rare in a world full of shipping cycles and sprint tickets.</p><p>So if you’re a dev and you vibe with physics too — this one’s for you. The builders, the thinkers, the ones whose curiosity regularly hijacks their productivity.</p><p>Next time your code gets ghosted by the PM, your side project dies in beta, or no one claps during demo day — just remember.</p><blockquote><em>At least you didn’t invent the future and die feeding pigeons.</em></blockquote><p>If this resonates with you — whether you’re a code-slinger, physics nerd, or just someone who’s been ghosted by their own genius — drop a comment. Would love to hear how <em>your</em> Tesla moment played out.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ae4dc1814ce9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding null in Flutter: Think of null as a "Maybe Box"]]></title>
            <link>https://medium.com/@aasifalee.114/understanding-null-in-flutter-think-of-null-as-a-maybe-box-d6ec7923f7c7?source=rss-ad7354b8f267------2</link>
            <guid isPermaLink="false">https://medium.com/p/d6ec7923f7c7</guid>
            <category><![CDATA[null]]></category>
            <category><![CDATA[dart]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[safety]]></category>
            <category><![CDATA[beginnertips]]></category>
            <dc:creator><![CDATA[Asif Ali Sheikh]]></dc:creator>
            <pubDate>Mon, 21 Jul 2025 07:22:22 GMT</pubDate>
            <atom:updated>2025-07-21T07:30:53.932Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Understanding null in Flutter: Think of null as a &quot;Maybe Box&quot;.</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*M44zcN31dkCBgeAQ2tmVeA.png" /><figcaption><strong>Maybe Box</strong></figcaption></figure><h3>“null” is like an unopened gift box — it might have something, or it might be empty.</h3><h3>The “Maybe Box” Analogy</h3><p>Imagine you’re building a Flutter app, and each variable is like a <strong>box</strong> that holds a value. Most boxes are filled with something — a string, a number, a widget. But some boxes come with a tag: “Maybe there’s something inside.”</p><p>These are <strong>nullable</strong> boxes — variables declared with a ?.</p><pre>String? maybeName; // This box *might* contain a name, or it might be empty (null)</pre><h3>Why This Analogy Helps</h3><p>Beginners often confuse null with other things:</p><ul><li>&quot;&quot; — an empty string (but still something)</li><li>0 — a number (also something)</li><li>false — a boolean (again, something)</li></ul><p>But null is <strong>nothing</strong>. The box exists, but it may be empty.</p><p>That’s why when you try to open a null box <strong>without checking</strong>, your app crashes.</p><h3>How to Check the Box Safely</h3><h3>✅ Peek Inside the Box</h3><pre>if (maybeName != null) {<br>  print(&#39;Name is: $maybeName&#39;);<br>} else {<br>  print(&#39;Box is empty&#39;);<br>}</pre><h3>✅ Use a Default Value</h3><pre>String name = maybeName ?? &#39;Guest&#39;; // If the box is empty, use &#39;Guest&#39;</pre><h3>✅ Use Safe Access</h3><pre>int? nameLength = maybeName?.length; // Returns null if the box is empty</pre><h3>🚫 What Happens If You Force It Open?</h3><pre>print(maybeName!.length); // 💥 CRASHES if the box is empty</pre><p>The ! means: “I <em>promise</em> this box isn’t empty.” But if it is — your app crashes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/328/1*tQHVVJfUwQBG1khuYiRloQ.gif" /><figcaption>Brutal Crash</figcaption></figure><h3>📍 Where You’ll See “Maybe Boxes” in Flutter</h3><ul><li>API data (e.g. user?.email)</li><li>Optional widget parameters (like hintText, icon)</li><li>Form inputs that haven’t been filled yet</li><li>App state that is initialized later</li></ul><pre>User? currentUser;</pre><h3>Null Safety = Mindful Programming</h3><p>Dart’s null safety teaches you to <strong>think before you open the box</strong>. You must be intentional. If it can be empty, <strong>say so</strong>. If it can’t, <strong>ensure it’s initialized.</strong></p><pre>String name = &#39;Flutter&#39;; // Always contains something — no surprises<br>String? nickname;        // Might be empty — use with care</pre><h3>Wrap-Up: From Confusion to Clarity</h3><p>Concept Analogy Meaning String Full box Always has a value String? Maybe box Might have a value or be empty ?, ??, ! Safe openers or defaults Help you work with &quot;maybe boxes&quot;</p><h3>Final Thought for Beginners</h3><blockquote><em>If you treat </em><em>null as a &quot;maybe box,&quot; you’ll develop the instinct to check what&#39;s inside before using it — just like you’d never eat from a container you’re not sure is full.</em></blockquote><p>By seeing null as an intentional <strong>design decision</strong>, not an error, you’ll write safer, cleaner, and more Flutter-ful code.</p><p>Absolutely — here’s a more engaging and conversational version that feels personal, inviting, and compelling:</p><h3>Thanks for Unboxing null with Me!</h3><p>If you’ve made it this far, you’ve just leveled up your Flutter mindset. 🎯<br> Understanding null isn’t just a technical skill — it’s a mindset shift. And now, you’re thinking in <strong>Maybe Boxes</strong>.</p><p>If this analogy sparked an “aha!” moment,<br> <strong>Tap that clap </strong>to help others discover it too<br> <strong>Drop a comment</strong> — even just one word: <em>“Helpful,”</em> <em>“Confused,”</em> or <em>“More please!” or </em>next Flutter concept that’s confusing you.<br>I read every comment, and your feedback shapes what comes next.</p><p>Let’s make Flutter simpler, together.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d6ec7923f7c7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Contextful Apps: Designing for Human Awareness in a Digital World]]></title>
            <link>https://medium.com/@aasifalee.114/contextful-apps-designing-for-human-awareness-in-a-digital-world-d9c7b1ec9a2b?source=rss-ad7354b8f267------2</link>
            <guid isPermaLink="false">https://medium.com/p/d9c7b1ec9a2b</guid>
            <category><![CDATA[flutter-app-development]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[mobile-development]]></category>
            <category><![CDATA[intelligent-apps]]></category>
            <category><![CDATA[contextfull-apps]]></category>
            <dc:creator><![CDATA[Asif Ali Sheikh]]></dc:creator>
            <pubDate>Fri, 18 Jul 2025 09:46:40 GMT</pubDate>
            <atom:updated>2025-07-21T05:03:51.330Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*0GbDbAWGdUe8-BUBlycAAQ.jpeg" /></figure><h4>What Are Contextful Apps?</h4><p><strong>Contextful apps</strong> are like that one friend who always seems to <em>get</em> you. They’re aware of your situation: the <strong>time</strong>, your <strong>location</strong>, your <strong>activity</strong>, your <strong>mood</strong> (yes, even the “I forgot my umbrella and it’s raining” kind of mood). They take all that into account and respond in a way that feels — dare I say — thoughtful.</p><blockquote><em>🟧 A </em>context-less<em> app reminds you to drink water every hour, even if you’re literally swimming.<br> 🟩 A </em>contextful<em> app notices you just finished a run and reminds you to rehydrate. That’s awareness.</em></blockquote><h4>A Dev’s Perspective</h4><p>As a Flutter developer building cross-platform apps for the past three years, I’ve watched mobile UI trends <strong>rise</strong> and <strong>fall</strong> — and yes, I’ve seen the <strong>Liquid Glass Design</strong> debates light up dev chats like wildfire. While some folks are busy arguing over gradients, glassmorphism, and whether that ripple is <em>liquid enough</em>, here’s the truth: no amount of polish can save an app that’s clueless about its user.</p><p>In <strong>2025</strong>, users expect apps that <em>understand</em> them — where they are, what they’re doing, and what they need next. That’s why the real future isn’t just aesthetic — it’s <strong>contextful</strong>.</p><p>We’re entering the age of <strong>adaptive intelligence</strong> — apps that adjust not just to users, but to <em>moments</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/220/1*9QXdW6VxNqF8dJHoGRO1TA.gif" /><figcaption>why does it matter?</figcaption></figure><h4>Why Context Matters (And Why You Should Care)</h4><p>Let’s be real: most apps today feel like that one coworker who always sends messages… but never reads the room.</p><p>Notifications at midnight. Reminders while you’re driving. Pop-ups while you’re presenting. We’ve all been there. And users? They’re <em>done</em> with it.</p><p>In this noisy, overloaded, and increasingly hybrid world, what users want isn’t more features — it’s <strong>relevance</strong>. They want software that <em>respects their time, understands their situation, and fits into their lives like it actually belongs there</em>.</p><p>This is where <strong>contextful apps</strong> come in — not just apps that work, but apps that <em>get it</em>.</p><h4>Where Does Context Come From?</h4><p>Apps can gather context from a variety of signals, including:</p><ul><li><strong>Time</strong> — Is it Monday morning or Saturday night Netflix o’clock?</li><li><strong>Location</strong> — Are you at home, at work, or in the middle of nowhere (a.k.a. rural Wi-Fi purgatory)?</li><li><strong>Activity</strong> — Walking? Driving? Power lounging?</li><li><strong>Device state</strong> — Battery at 4%? Bluetooth on? Headphones connected?</li><li><strong>Environment</strong> — Rain, heat, noise, darkness?</li><li><strong>History</strong> — What have you been doing lately? (No judgment.)</li></ul><p>The more intelligently we combine these <em>signals</em>, the more <em>human</em> our apps start to feel.</p><h4>Real-World Examples of Contextful Apps</h4><h4>🧭 Google Assistant &amp; Siri</h4><p>Remind you to leave early for a meeting if traffic is a mess. Basically, your <em>passive-aggressive</em> calendar with GPS.</p><h4>🏃 Strava</h4><p>Auto-detects if you’re <em>cycling</em> or <em>running</em>. Can’t fool it with a power walk.</p><h4>🚦 Waze</h4><p>Changes <em>interface</em> and <em>routing</em> based on your driving conditions and habits. Sometimes it feels more stressed than you are.</p><h4>🛏️ Smart Home Apps (e.g., Hue, Nest)</h4><p>Lights that <em>dim</em> when it’s bedtime. Thermostats that go <em>eco-mode</em> when you leave. Tech that cares.</p><h4>📱 iOS Focus Modes</h4><p>Your phone knows when you’re <em>working</em>, <em>relaxing</em>, or <em>socializing</em> and adjusts <em>notification</em> behavior accordingly. Feels <em>spooky</em>. Works great.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/220/1*WE9yoEMAP8YXnS1hHKbsQw.gif" /><figcaption>Not that easy…</figcaption></figure><h4><strong>But It’s Not All Smooth Sailing…</strong></h4><p>Building contextful apps has its challenges. Trust me — I’ve been there.</p><h4>🔐 1. Privacy &amp; Ethics</h4><p>Just because you <em>can</em> collect data doesn’t mean you <em>should</em>. Be transparent and give users full control.</p><h4>🔋 2. Battery Drain</h4><p>Constant sensor usage = apps that eat batteries for breakfast. Optimize or risk the 1-star reviews.</p><h4>🤔 3. Misinterpretation</h4><p>If your app thinks the user is exercising on a bumpy train ride, you’ve got a problem. Context isn’t always right.</p><h4>📱 4. Cross-device Complexity</h4><p>Context lives across phones, watches, laptops, and cars. Syncing them? That’s a boss-level task.</p><h4>Best Practices for Designing Contextful Apps</h4><p>Here’s what I’ve learned (sometimes the hard way):</p><ol><li><strong>Start with intent, not sensors:</strong><br> Don’t collect data just to collect it. Know what experience you want to improve.</li><li><strong>Be transparent:</strong><br> Let users know what data you’re using — and why. Bonus points if your explanation is actually readable.</li><li><strong>Assist, don’t override:</strong><br> Context should guide, not hijack. Nobody likes an app that thinks it knows better than you.</li><li><strong>Give opt-in control:</strong><br> Let users decide how deep the context rabbit hole goes.</li><li><strong>Fail gracefully:</strong><br> If context isn’t available, your app should still function without freaking out.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/220/1*_VSCHByzPbquBby5s6qqHg.gif" /><figcaption>Future full of context</figcaption></figure><h4>The Future Is Context-Rich</h4><p>The apps of the near future won’t just respond — they’ll <em>preempt</em>. They’ll learn patterns, understand environments, and maybe even check your vibe (yes, even your vibe).</p><p>We’re building toward proactive computing — where your devices behave more like thoughtful companions and less like… needy digital toddlers.</p><h4>Final Thoughts (and a Flutter Bias)</h4><p>As someone building with Flutter, I’m loving how easy it is to tap into native device capabilities — from geolocation to activity sensors — and to pair that with AI tools like Firebase ML Kit, local models, and context-aware UIs.</p><p>Even a little context can go a long way. A single smart suggestion, a subtle UI shift, or a well-timed nudge can turn a decent app into a delightful one.</p><blockquote><em>Let’s stop building apps that just sit there and wait.<br>Let’s build apps that </em>stretch<em>, </em>yawn<em>, and </em>meet<em> the user halfway.</em></blockquote><p>✌️ <em>Thanks for reading! If you’re working on a contextful feature or have a story of an app that got a little too smart, I’d love to hear it. Let’s connect and talk shop.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/220/1*ZkrtIHk9RDg-VQs-U8Iu-A.gif" /><figcaption>BY-BY</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d9c7b1ec9a2b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ Securing API Calls in Flutter Using AES-GCM, HMAC, and GUID-based Secrets]]></title>
            <link>https://medium.com/@aasifalee.114/securing-api-calls-in-flutter-using-aes-gcm-hmac-and-guid-based-secrets-70c0dacd436d?source=rss-ad7354b8f267------2</link>
            <guid isPermaLink="false">https://medium.com/p/70c0dacd436d</guid>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[security-encryption-api]]></category>
            <category><![CDATA[secure-api]]></category>
            <category><![CDATA[encryption]]></category>
            <category><![CDATA[decryption]]></category>
            <dc:creator><![CDATA[Asif Ali Sheikh]]></dc:creator>
            <pubDate>Thu, 12 Jun 2025 09:32:20 GMT</pubDate>
            <atom:updated>2025-06-12T09:32:20.069Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kqiyIYyB6_qoOEfZTotOMA.jpeg" /><figcaption>AES-GCM Encryption</figcaption></figure><p>In modern mobile applications, safeguarding sensitive data during client-server communication is critical. While HTTPS provides a basic layer of protection, custom encryption schemes like <strong>AES-GCM with HMAC authentication</strong> offer <strong>defense-in-depth</strong> and protection against advanced threats such as man-in-the-middle (MITM) attacks and data tampering.</p><p>This guide demonstrates how to <strong>secure Flutter API calls</strong> using:</p><ul><li><strong>AES/GCM/NoPadding</strong> for encryption,</li><li>A shared private <strong>master </strong>key,</li><li>Dynamic secret key per transaction derived from a <strong>GUID</strong>, and</li><li><strong>HMAC </strong>for authenticity and integrity.</li></ul><h3>🧱 Architecture Overview</h3><h3>🔑 Key Concepts:</h3><p><strong>Component Description</strong></p><p><strong>Master Key </strong>A 256-bit private key stored securely on both client and server.</p><p><strong>GUID (32-bit) </strong>Unique ID generated per transaction.</p><p><strong>SECRET_KEY </strong>AES-encrypted GUID using the Master Key (used for that specific transaction).</p><p><strong>AUTH_KEY </strong>HMAC-based key derived from the GUID. Used to verify message integrity.</p><p><strong>Encryption </strong>AES/GCM/NoPadding with random IV and 256-bit keys.</p><h3>🔐 Step-by-Step Encryption Workflow in Flutter</h3><h3>✅ Prerequisites</h3><p>Install dependencies:</p><pre>dependencies:<br>  encrypt: ^5.0.1<br>  crypto: ^3.0.3<br>  uuid: ^4.0.0</pre><h3>1. 🎯 Generate a 32-bit GUID per transaction</h3><pre>import &#39;package:uuid/uuid.dart&#39;;<br>final guid = Uuid().v4().substring(0, 8); // 32-bit = 8 characters (hex)</pre><h3>2. 🔒 Encrypt the GUID using the Master Key → SECRET_KEY</h3><pre>import &#39;package:encrypt/encrypt.dart&#39; as encrypt;<br><br><br>final masterKey = encrypt.Key.fromUtf8(&quot;your-256-bit-master-key-here&quot;); // 32-byte<br>final iv = encrypt.IV.fromSecureRandom(12); // 96-bit IV for GCM<br>String encryptGuid(String guid, encrypt.Key masterKey, encrypt.IV iv) {<br>  final encrypter = encrypt.Encrypter(encrypt.AES(masterKey, mode: encrypt.AESMode.gcm));<br>  final encrypted = encrypter.encrypt(guid, iv: iv);<br>  return base64Encode(encrypted.bytes); // Encrypted GUID (SECRET_KEY)<br>}</pre><h3>3. 🔐 Generate AUTH_KEY from the GUID using HMAC</h3><pre>import &#39;package:crypto/crypto.dart&#39;;<br>import &#39;dart:convert&#39;;<br><br>String generateAuthKey(String guid) {<br>  final key = utf8.encode(guid);<br>  final message = utf8.encode(&#39;AUTHENTICATION&#39;);<br>  final hmacSha256 = Hmac(sha256, key);<br>  final digest = hmacSha256.convert(message);<br>  return base64Encode(digest.bytes);<br>}</pre><h3>4. 🔐 Encrypt the Payload using AES-GCM and SECRET_KEY</h3><pre>String encryptPayload(String plainText, encrypt.Key secretKey, encrypt.IV iv) {<br>  final encrypter = encrypt.Encrypter(encrypt.AES(secretKey, mode: encrypt.AESMode.gcm));<br>  final encrypted = encrypter.encrypt(plainText, iv: iv);<br>  return base64Encode(encrypted.bytes);<br>}</pre><h3>5. 📡 Prepare and Send the API Request</h3><pre>final guid = Uuid().v4().substring(0, 8);<br>final iv = encrypt.IV.fromSecureRandom(12);<br><br>final secretKeyEncrypted = encryptGuid(guid, masterKey, iv); // For transport<br>final authKey = generateAuthKey(guid); // For message verification<br>// Use guid directly as key for AES payload encryption<br>final payloadKey = encrypt.Key.fromUtf8(guid.padRight(32, &#39;0&#39;)); // Pad to 256-bit<br>final payload = jsonEncode({&#39;username&#39;: &#39;user123&#39;, &#39;password&#39;: &#39;secret&#39;});<br>final encryptedPayload = encryptPayload(payload, payloadKey, iv);<br>final requestBody = jsonEncode({<br>  &#39;data&#39;: encryptedPayload,<br>  &#39;iv&#39;: base64Encode(iv.bytes),<br>  &#39;secret_key&#39;: secretKeyEncrypted,<br>  &#39;auth_key&#39;: authKey,<br>});</pre><p>Send the above requestBody to your API using http.post.</p><h3>🔄 Server-Side Processing (Outline)</h3><p><strong>On the server:</strong></p><ol><li>Decrypt the secret_key using the Master Key and IV to recover the original GUID.</li><li>Use the decrypted GUID to:</li></ol><ul><li>Derive the HMAC and compare with auth_key.</li><li>Use as the AES key to decrypt the payload.</li></ul><p>3. Verify message integrity and process securely.</p><h3>🛡 Best Practices</h3><ul><li><strong>Secure Key Storage</strong>: Use Flutter Secure Storage for the Master Key.</li><li><strong>SSL/TLS</strong>: Always use HTTPS; encryption is an additional layer.</li><li><strong>Logging</strong>: Never log GUIDs, payloads, or keys in production.</li><li><strong>Nonce Management</strong>: Ensure IVs are unique per encryption.</li><li><strong>Key Rotation</strong>: Rotate your Master Key periodically and handle versioning.</li></ul><h3>✅ Conclusion</h3><p>By combining <strong>AES-GCM</strong>, <strong>HMAC</strong>, and <strong>per-transaction secrets</strong>, you create a secure framework for API communication in Flutter that resists eavesdropping, tampering, and MITM attacks. This layered approach significantly strengthens your app’s security posture, particularly when dealing with sensitive user data.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=70c0dacd436d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[️ Enforcing Single-Session Login in a Flutter App: Auto Session Kill on App Close]]></title>
            <link>https://medium.com/@aasifalee.114/%EF%B8%8F-enforcing-single-session-login-in-a-flutter-app-auto-session-kill-on-app-close-e38dd69ae8aa?source=rss-ad7354b8f267------2</link>
            <guid isPermaLink="false">https://medium.com/p/e38dd69ae8aa</guid>
            <category><![CDATA[single-session]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[enforcing-single-session]]></category>
            <category><![CDATA[session-management]]></category>
            <dc:creator><![CDATA[Asif Ali Sheikh]]></dc:creator>
            <pubDate>Wed, 07 May 2025 12:21:43 GMT</pubDate>
            <atom:updated>2025-07-17T06:57:08.943Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TUneUkZhv-wpvIkXEU28bw.jpeg" /></figure><p><strong>Scenario:</strong> In many applications — especially in financial or enterprise sectors — users are restricted from logging in on multiple devices at the same time. This requires robust <strong>session management</strong> with a crucial need: <strong>automatically delete a session when the app is closed or killed</strong>.</p><p>In this article, we’ll walk through:</p><ul><li>Why this problem exists</li><li>Challenges with app lifecycle in mobile and web</li><li>How to implement <strong>session cleanup on app termination</strong></li><li>Using platform-specific approaches for <strong>Android and Flutter Web</strong></li></ul><h3>🚨 The Problem: Concurrent Sessions</h3><p>Let’s say you’re building an app where each agent can only be logged in on one device. If a user logs in on another device while still active on the first, the second session fails — unless we clean up the first session.</p><p>But here’s the challenge:</p><blockquote><em>Most users </em><strong><em>don’t log out manually.</em></strong><em> They just swipe the app away or close the tab.</em></blockquote><p>If you don’t handle this gracefully, users will be locked out by a ghost session. 😬</p><h3>🧩 The Challenge: Detecting App Termination</h3><p>Unfortunately, app termination is tricky to detect reliably:</p><h3>🟢 On Android</h3><ul><li>If a user swipes the app away or removes it from recent tasks, onTaskRemoved() in a <strong>Foreground Service</strong> is your friend.</li></ul><h3>🟠 On Flutter Web</h3><ul><li>You can hook into window.onBeforeUnload to trigger last-second cleanup.</li></ul><h3>🔴 On iOS (not covered here)</h3><ul><li>More restrictive and unreliable for background tasks.</li></ul><h3>✅ Our Goal</h3><p>We want to <strong>delete the user session on app close</strong> (whether it’s mobile or web) by calling an API like:</p><pre>https://api/WebApiRequest/PostRequestinfo/{value}<br>{<br>  &quot;apiName&quot;: &quot;Delete_Session&quot;,<br>  ...<br>}</pre><h3>🔧 Implementation: Android Foreground Service</h3><p>To handle Android app termination, we’ll use a <strong>Foreground Service</strong>:</p><pre>class SessionKillService : Service() {<br>private var userId: String? = null<br>private var sessionId: String? = null<br>override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {<br>        startForeground(1, createNotification())<br>        merchantId = intent?.getStringExtra(&quot;merchantId&quot;)<br>        sessionId = intent?.getStringExtra(&quot;sessionId&quot;)<br>        return START_STICKY<br>    }<br>    override fun onTaskRemoved(rootIntent: Intent?) {<br>        sendDeleteSessionRequest(merchantId, sessionId)<br>        stopSelf()<br>        super.onTaskRemoved(rootIntent)<br>    }<br>}</pre><p>This service is started from Flutter using a MethodChannel, triggered when login is successful.</p><h3>Flutter Dart Side:</h3><pre>void triggerSessionKillService({String? merchantId, String? sessionId}) {<br>  const platform = MethodChannel(&#39;app.lifecycle.channel&#39;);<br>  platform.invokeMethod(&#39;triggerService&#39;, {<br>    &quot;merchantId&quot;: merchantId ?? &quot;&quot;,<br>    &quot;sessionId&quot;: sessionId ?? &quot;&quot;,<br>  });<br>}</pre><p>Now if the app is swiped away, the session delete request is fired via the native service.</p><h3>🕸️ Implementation: Flutter Web Using sendBeacon</h3><p>For web, the sendBeacon API allows us to send <strong>non-blocking data</strong> even as the browser tab is closing:</p><pre>html.window.onBeforeUnload.listen((event) {<br>  final data = { ... }; // JSON payload<br>  final blob = html.Blob([jsonEncode(data)], &#39;application/json&#39;);<br>  html.window.navigator.sendBeacon(webhookUrl, blob);<br>});</pre><p>This is perfect for short, critical requests that <strong>must be sent before unload</strong>.</p><blockquote><em>⚠️ Avoid async/await or standard </em><em>http.post() inside </em><em>onBeforeUnload — the browser may terminate it.</em></blockquote><h3>🔍 Debugging with Webhook.site</h3><p>To test this behavior, use <a href="https://webhook.site/">https://webhook.site</a>:</p><ul><li>It gives you a temporary endpoint to receive HTTP POST requests</li><li>You can inspect headers, payload, and status in real time</li></ul><p>Just paste the generated URL in your sendBeacon code and trigger a page close. Magic! ✨</p><h3>🧠 Wrap-Up</h3><p>This pattern helps you maintain strict session control in Flutter apps by:</p><ul><li>Running a native background service on Android to detect task removal</li><li>Leveraging the browser’s onBeforeUnload for Flutter Web</li><li>Ensuring that no orphan sessions are left open</li></ul><p>🔒 It’s a simple but effective way to <strong>enforce single-session login</strong> and avoid frustrating login issues due to stale sessions.</p><h3>💡 Pro Tips</h3><ul><li>For iOS: Consider using server-side session expiry policies, as background execution is limited.</li><li>For Flutter desktop apps: Lifecycle management APIs are platform-dependent and evolving.</li><li>Always fallback gracefully — like allowing a “force login” option to invalidate prior sessions.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e38dd69ae8aa" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>