<?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 Hafiz Umar Ahmad Siddiqui on Medium]]></title>
        <description><![CDATA[Stories by Hafiz Umar Ahmad Siddiqui on Medium]]></description>
        <link>https://medium.com/@h.umarahmad107?source=rss-425a189b8b4f------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*n5Z07E8_-VaRZYKf-u9U-w.jpeg</url>
            <title>Stories by Hafiz Umar Ahmad Siddiqui on Medium</title>
            <link>https://medium.com/@h.umarahmad107?source=rss-425a189b8b4f------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 08:45:33 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@h.umarahmad107/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[Activities Are Not Screens — Android’s Mental Model]]></title>
            <link>https://medium.com/@h.umarahmad107/activities-are-not-screens-androids-mental-model-37ac30da95bd?source=rss-425a189b8b4f------2</link>
            <guid isPermaLink="false">https://medium.com/p/37ac30da95bd</guid>
            <category><![CDATA[flutter-vs-native]]></category>
            <category><![CDATA[andriod]]></category>
            <category><![CDATA[jetpack-compose]]></category>
            <category><![CDATA[native-development]]></category>
            <category><![CDATA[android-app-development]]></category>
            <dc:creator><![CDATA[Hafiz Umar Ahmad Siddiqui]]></dc:creator>
            <pubDate>Tue, 11 Aug 2026 04:01:02 GMT</pubDate>
            <atom:updated>2026-08-11T04:01:02.205Z</atom:updated>
            <content:encoded><![CDATA[<p>The first assumption Flutter developers make about Activities is that they map one-to-one with screens. One screen = one Activity.</p><p>That’s not quite right — and the distinction changes how you think about everything else.</p><h3>What an Activity Actually Is</h3><p>An Activity is a <strong>window</strong> — a container that the OS has allocated for your app to present UI and receive user interaction. It’s not a route. It’s not a page. It’s a window.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/958/1*icGyoKisGGNgKPYqGtl0gg.png" /></figure><p>The key difference is who manages it.</p><p>In Flutter, you manage your own navigation stack. You push routes, you pop them, you decide what’s visible and when. You’re in control of the stack.</p><p>In Android, the OS manages windows. It creates Activities, pauses them, resumes them, destroys them, and recreates them — on its own schedule, based on system needs.</p><h3>One Application, Many Activities</h3><p>Every Android app has one Application object — one per app process. It&#39;s the long-lived container. Activities are what come and go underneath it:</p><pre>Application<br>     │<br>     ├── Activity A<br>     ├── Activity B<br>     └── Activity C</pre><p>At any point, the OS can:</p><ul><li>Pause one Activity when another comes into the foreground</li><li>Resume an Activity when the user returns to it</li><li>Destroy an Activity to reclaim memory</li><li>Keep the Application alive even when no Activity is visible</li><li>Recreate an Activity after a configuration change like screen rotation</li></ul><p>Your app has no direct control over when any of this happens. You respond to it.</p><h3>Lifecycle Methods Are the OS Talking</h3><p>onCreate(), onPause(), onResume(), onDestroy() — these are notifications from the OS telling your Activity what&#39;s happening.</p><p>You don’t invoke them. They arrive.</p><p>When the OS pauses your Activity because another app came to the foreground, onPause() gets called. You respond by saving any state that needs to survive. When the user comes back, onResume() gets called. You restore from where you left off.</p><p>The OS decides the timing. Your job is to write the right response to each notification.</p><h3>Back Doesn’t Kill the App</h3><p>This surprised me.</p><p>Pressing Back finishes the current Activity — it does not kill the entire app process.</p><p>The Application object stays alive. Background services keep running. Any state stored outside the Activity remains in place. Only the visible Activity gets finished.</p><p>The Activity and the app process are separate things. One can end without ending the other.</p><h3>Activity Is Just One Component</h3><p>Activity is one of four major component types in Android:</p><ul><li><strong>Activity</strong> — the visible, interactive window</li><li><strong>Service</strong> — runs background operations without any UI</li><li><strong>BroadcastReceiver</strong> — listens to system-wide events</li><li><strong>ContentProvider</strong> — manages and shares data across apps</li></ul><p>Everything in Android is a component. Activity is just the one that shows up on screen.</p><h3>The Mental Model</h3><p>Coming from Flutter, the Navigator feels like the natural way to think about screens — you own the stack, you control the flow.</p><p>Android’s model is different: the OS owns the windows. You write Activities, declare them in the Manifest, and handle the lifecycle notifications that arrive. The OS decides the rest.</p><p>Once that mental model is in place, questions like “why does my Activity get recreated on rotation?” or “why is Back not killing my app?” stop being confusing — they’re just the OS doing its job.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=37ac30da95bd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[State in Jetpack Compose — For Someone Who Knows Flutter]]></title>
            <link>https://medium.com/@h.umarahmad107/state-in-jetpack-compose-for-someone-who-knows-flutter-00266f890b0b?source=rss-425a189b8b4f------2</link>
            <guid isPermaLink="false">https://medium.com/p/00266f890b0b</guid>
            <category><![CDATA[state-management]]></category>
            <category><![CDATA[jetpack-compose]]></category>
            <category><![CDATA[andriod-app-development]]></category>
            <category><![CDATA[flutter-vs-native]]></category>
            <category><![CDATA[andriod]]></category>
            <dc:creator><![CDATA[Hafiz Umar Ahmad Siddiqui]]></dc:creator>
            <pubDate>Mon, 10 Aug 2026 04:01:01 GMT</pubDate>
            <atom:updated>2026-08-10T04:01:01.840Z</atom:updated>
            <content:encoded><![CDATA[<h3>The Problem with Plain Variables</h3><p>In Compose, a plain variable doesn’t work the way you’d expect.</p><pre>var count = 0</pre><p>Compose doesn’t watch this. When count changes, nothing happens on screen. The UI has no idea anything changed, it just keeps showing whatever it showed before.</p><p>To make Compose react to a value, that value has to live in state:</p><pre>var count by remember { mutableStateOf(0) }</pre><p>Now when count changes, Compose sees it and re-renders automatically. No manual call. No notification. Just the change itself triggers the update.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/516/1*McX34orUCrQ07S1n_4hMsg.jpeg" /></figure><h3>The Flutter Parallel</h3><p>In Flutter, you hold state in a StatefulWidget and call setState() to trigger a rebuild:</p><pre>setState(() {<br>  count++;<br>});</pre><p>In Compose, you just change the value — and because it’s wrapped in mutableStateOf, Compose reacts on its own:</p><pre>count++  // Compose sees this and recomposes automatically</pre><p>Flutter is <strong>imperative</strong> about state — you call setState() and tell it to rebuild. Compose is <strong>reactive</strong> — it watches the state object and recomposes whenever it changes.</p><p>The end result is the same. The mechanism is different.</p><h3>What remember Does</h3><p>Every time Compose runs a composable, it re-executes the function from scratch. Without remember, every re-composition would reset local variables back to their initial value — losing whatever state had built up.</p><p>remember holds a value across recompositions:</p><pre>var count by remember { mutableStateOf(0) }<br>//                ↑<br>//           survives recomposition</pre><p>Both parts work together:</p><ul><li>mutableStateOf(0) makes the value observable — Compose watches it for changes</li><li>remember { } makes it survive recomposition — the value isn&#39;t lost when the function re-executes</li></ul><p>Remove either one and it breaks. Without mutableStateOf, Compose won&#39;t react. Without remember, the value resets every recomposition.</p><h3>Re-composition Is Not a Full Redraw</h3><p>Important distinction: re-composition does not mean the entire screen redraws.</p><p>When a state value changes, Compose only reruns the composables that depend on that specific state — not everything. The rest of the UI is left alone. It’s targeted and efficient.</p><p>And re-composition is triggered by <strong>state changes</strong>, not by events. You don’t tell Compose “redraw now.” You change a state value, and Compose reacts to that change on its own terms.</p><h3>remember vs ViewModel</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/946/1*R_L2yNnYltzx2y3l57WeEg.png" /></figure><p>remember keeps state alive across re-compositions, but not across Activity recreation. If the device rotates, or the system triggers a configuration change, remember values are gone.</p><p>For state that needs to survive that:</p><pre>remember    →  survives recomposition<br>              lost when Activity is recreated (rotation, config change)</pre><pre>ViewModel   →  survives re-composition<br>              survives Activity recreation too</pre><p>remember is for UI-local state — things that only matter within the current composition. ViewModel is for screen-level state — anything that should outlive the Activity.</p><p>The rule: if it needs to survive a screen rotation, it doesn’t belong in remember.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=00266f890b0b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[From XML to Jetpack Compose — Why Declarative UI Won]]></title>
            <link>https://medium.com/@h.umarahmad107/from-xml-to-jetpack-compose-why-declarative-ui-won-759f8c455d64?source=rss-425a189b8b4f------2</link>
            <guid isPermaLink="false">https://medium.com/p/759f8c455d64</guid>
            <category><![CDATA[jetpack-compose]]></category>
            <category><![CDATA[xml]]></category>
            <category><![CDATA[compose-vs-xml]]></category>
            <category><![CDATA[andriod]]></category>
            <dc:creator><![CDATA[Hafiz Umar Ahmad Siddiqui]]></dc:creator>
            <pubDate>Sun, 09 Aug 2026 04:01:01 GMT</pubDate>
            <atom:updated>2026-08-09T04:01:01.682Z</atom:updated>
            <content:encoded><![CDATA[<h3>The Old Way: XML and Imperative UI</h3><p>In XML-based Android, the UI and the logic were always in two separate places — and every state change required bridging the gap manually.</p><p>When something in the app changed, the update process looked like this:</p><pre>State changes → Find the view → Update the view → Notify adapter → Refresh UI</pre><p>Every step had to be handled explicitly. You reached into the view hierarchy, found the specific element that needed to change, updated it, then made sure everything else caught up. If you forgot a step, the UI would be out of sync.</p><p>You weren’t describing what the UI <em>should</em> look like. You were telling it <em>what to do</em>.</p><h3>“Find This Button” vs “Here’s What It Should Look Like”</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/738/1*cSArl27Box9giLthNyabvQ.png" /></figure><p>The mental model in XML was imperative — step by step instructions aimed at specific views:</p><blockquote><em>“Find the TextView with ID </em><em>username_label. Set its text to the new value. Now notify the RecyclerView adapter. Now refresh.&quot;</em></blockquote><p>Flutter changed the model entirely:</p><blockquote><em>“Here is what the UI should look like when the state is X.”</em></blockquote><p>No finding. No manual updates. You describe the desired result, and the framework figures out what changed between the old state and the new one.</p><p>Jetpack Compose adopted the same model. Both Flutter and Compose compare the previous UI with the new one and apply only the differences. You never reach in and update a specific view — you hand the framework a new description and let it handle the diffing.</p><p>This is called <strong>declarative UI</strong>.</p><h3>The Comparison</h3><p><strong>XML — Imperative:</strong></p><pre>State changes<br>    ↓ Find the view<br>    ↓ Update the view<br>    ↓ Notify adapter<br>    ↓ Refresh UI</pre><p>You manually coordinate every step. One missed notification = stale UI.</p><p><strong>Flutter / Compose — Declarative:</strong></p><pre>State changes<br>    ↓ Describe the new UI<br>    ↓ Framework diffs old vs new<br>    ↓ Only changed parts update</pre><p>You describe the result. The framework handles the rest.</p><h3>Why This Matters</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/981/1*f4hi5N1C7eTB4bKifZeDXA.png" /></figure><p>In XML, as the app grows, the chain of manual updates gets longer and harder to trace. A state change in one part of the screen can require finding multiple views, notifying adapters in the right order, and carefully coordinating refreshes. Things get scattered.</p><p>With declarative UI, the description and the data are always tied together. When state changes, the UI re-renders to match — automatically. There’s no gap to manage, no sequence of steps to get right.</p><p>Flutter figured this out early, building the whole framework around it. Jetpack Compose brought the same model to native Android — and it changed how Android UI is written going forward.</p><p>The shift isn’t just syntactic. It’s a completely different relationship between data and UI.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=759f8c455d64" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Android Doesn’t Let You Be in Charge — and That’s the Point]]></title>
            <link>https://medium.com/@h.umarahmad107/android-doesnt-let-you-be-in-charge-and-that-s-the-point-20861e38e3d9?source=rss-425a189b8b4f------2</link>
            <guid isPermaLink="false">https://medium.com/p/20861e38e3d9</guid>
            <dc:creator><![CDATA[Hafiz Umar Ahmad Siddiqui]]></dc:creator>
            <pubDate>Sat, 08 Aug 2026 04:01:03 GMT</pubDate>
            <atom:updated>2026-08-08T04:01:03.401Z</atom:updated>
            <content:encoded><![CDATA[<p>Coming from Flutter, the default assumption is that you call things. runApp(), setState(), Navigator.push() — you decide when everything happens.</p><p>Android inverts that entirely.</p><h3>Inversion of Control</h3><p>When someone taps your app icon, Android creates an Activity and starts calling lifecycle methods on it. You didn’t request this. You didn’t time it. The OS decided.</p><p>This pattern has a name: <strong>Inversion of Control</strong>. Instead of your code calling the framework, the framework calls your code.</p><p>Lifecycle methods — onCreate(), onPause(), onResume(), onDestroy() — are not things you invoke. They&#39;re notifications arriving from the OS, letting you know what just happened or what&#39;s about to happen. Your job is to write responses to each one.</p><pre>Flutter:   you call runApp()    →  app starts<br>Android:   OS calls onCreate()  →  you respond</pre><p>The timing, the order, the trigger — all owned by Android. Not by you.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/970/1*RQuzNsMGpAxDibOQ6KqoiQ.png" /></figure><h3>Android Owns Object Creation Too</h3><p>It goes further than lifecycle. Android owns the creation and destruction of its own components.</p><p>Think about something as simple as opening the keyboard:</p><pre>Need keyboard → Create keyboard → Initialize keyboard → Show keyboard</pre><p>You don’t do any of this directly. You make a request, and the OS handles the chain. This is consistent throughout the system: you work with what Android provides, at the times Android chooses to provide it.</p><h3>Context: Not What Flutter Taught You</h3><p>Flutter has a BuildContext — it tells you where your widget sits in the widget tree.</p><p>Android’s Context answers a completely different question: <em>where are you in the application, and what OS resources can you access?</em></p><pre>Flutter Context  →  your position in the widget tree<br>Android Context  →  your access card to the OS</pre><p>Context in Android is how your code communicates with the system. Need to open another Activity? Go through Context. Need to access the file system, show a notification, or request a permission? Also Context.</p><p>Think of it as the reception desk — the front door to everything the OS offers.</p><h3>The Binder: How Everything Talks</h3><p>Almost nothing in Android runs in a single process. The camera, keyboard, Bluetooth, notifications, location, clipboard — all handled by separate system processes.</p><p>The <strong>Binder</strong> is Android’s inter-process communication system. It’s built into the kernel, it’s fast, and almost everything goes through it.</p><ul><li>Camera? Binder.</li><li>Keyboard? Binder.</li><li>Bluetooth, notifications, clipboard, location? All Binder.</li></ul><p>You never interact with Binder directly. But understanding it exists explains why everything in Android feels like a <em>request</em> — you’re always asking the OS, which talks to the right system service on your behalf.</p><h3>The Manifest: A Map the OS Reads</h3><p>Since the OS is in control of everything, it needs to know what your app is and what it can do — before it does anything.</p><p>The AndroidManifest.xml is that map. It&#39;s the identity card of the app.</p><p>The OS reads the manifest to understand:</p><ul><li>What Activities exist</li><li>What Services are registered</li><li>What Permissions the app needs</li><li>What BroadcastReceivers are listening</li><li>Which Activity to launch when the icon is tapped</li></ul><p>Metadata in the manifest describes the <em>behaviour</em> of the app. The manifest itself describes its <em>identity</em>.</p><p>Without it, the OS has no idea your app exists.</p><h3>The Pattern That Ties It All Together</h3><p>Inversion of Control isn’t a quirk — it’s the principle that explains every part of Android:</p><ul><li>Lifecycle methods exist because the OS needs to notify you what’s happening.</li><li>Context exists because the OS controls all system resources.</li><li>The Binder exists because the OS mediates everything between processes.</li><li>The manifest exists because the OS needs a map before it can manage your app.</li></ul><p>Stop trying to call things, and start writing good responses to what gets called.</p><p>That’s the shift.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=20861e38e3d9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Android Project Structure — Mapped to Flutter]]></title>
            <link>https://medium.com/@h.umarahmad107/android-project-structure-mapped-to-flutter-c723abd82ac7?source=rss-425a189b8b4f------2</link>
            <guid isPermaLink="false">https://medium.com/p/c723abd82ac7</guid>
            <category><![CDATA[android-project-structure]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[flutter-vs-native]]></category>
            <dc:creator><![CDATA[Hafiz Umar Ahmad Siddiqui]]></dc:creator>
            <pubDate>Fri, 07 Aug 2026 04:26:28 GMT</pubDate>
            <atom:updated>2026-08-07T04:26:28.251Z</atom:updated>
            <content:encoded><![CDATA[<p>The first thing I did when opening an Android project was look for things I already knew as a Flutter Developer. Here’s the direct translation.</p><h3>The Folder Structure</h3><pre>app/<br>├── manifests/<br>│   └── AndroidManifest.xml<br>├── java/<br>│   └── com.example.app/<br>│       └── MainActivity.kt<br>└── res/</pre><pre>build.gradle.kts</pre><p>Each piece has a Flutter equivalent — or a clear explanation for why it doesn’t.</p><h3>build.gradle.kts → pubspec.yaml</h3><p>Same job. Different file.</p><p>build.gradle.kts is where you manage:</p><ul><li>Dependencies (libraries and packages)</li><li>SDK version requirements</li><li>App version and build configuration</li><li>Plugin setup</li></ul><p>The only real difference is syntax — Flutter uses YAML, Android uses Kotlin script (.kts). Same purpose, different format.</p><h3>res/ → assets/</h3><p>res/ is Flutter&#39;s assets/ folder, with more structure.</p><p>It holds everything static the app needs:</p><ul><li>Drawables and images (res/drawable/)</li><li>Fonts (res/font/)</li><li>Strings, colours, dimensions (res/values/)</li></ul><p>Flutter’s assets/ folder is flat. res/ is organized into subfolders by type. Same idea — different level of organization.</p><h3>AndroidManifest.xml — No Flutter Equivalent</h3><p>This one has no direct Flutter equivalent, which is exactly why it matters.</p><p>The AndroidManifest.xml is the identity card of the app. Android reads it before doing anything else. It declares:</p><ul><li>Every Activity in the app</li><li>Every Service</li><li>Every BroadcastReceiver</li><li>What Permissions the app needs</li><li>The app theme</li><li>Which Activity launches when the icon is tapped (the Launcher Activity)</li></ul><p>Since the OS controls everything, it needs this map first. Without the manifest, Android doesn’t know the app exists, what it can do, or where to start.</p><h3>MainActivity → main() Entry Point</h3><p>MainActivity is the first thing Android creates when the app icon is tapped. It&#39;s the entry point — the Android equivalent of main() in Flutter.</p><p>It extends ComponentActivity, the base class for modern Android activities. It provides:</p><ul><li>Lifecycle management</li><li>Permission handling</li><li>Compose support</li><li>Core activity behaviour</li></ul><p>You don’t build this from scratch. You extend it and add your UI inside it.</p><h3>setContent {} → runApp()</h3><p>setContent is the Compose equivalent of runApp(). Everything inside that block becomes the UI.</p><pre>// Flutter<br>void main() {<br>  runApp(MyApp());<br>}</pre><pre>// Android + Compose<br>override fun onCreate(...) {<br>    setContent {<br>        MyApp()<br>    }<br>}</pre><p>Same concept — the entry point to the UI tree.</p><p>The path maps cleanly too:</p><pre>Flutter:  main() → runApp() → Widget tree → Screen<br>Android:  MainActivity → setContent{} → Composable tree → Screen</pre><h3>Widget → @Composable Function</h3><p>In Flutter, everything is a widget — a class with a build() method.</p><p>In Compose, everything is a function marked with @Composable.</p><pre>// Flutter<br>class MyText extends StatelessWidget {<br>  Widget build(BuildContext context) {<br>    return Text(&quot;Hello&quot;);<br>  }<br>}</pre><pre>// Compose<br>@Composable<br>fun MyText() {<br>    Text(&quot;Hello&quot;)<br>}</pre><p>Same purpose — describe a piece of UI. Different shape.</p><p>Flutter uses class inheritance. Compose uses function annotations. And instead of build() returning a widget tree, Compose re-executes the function when state changes — this is called recomposition.</p><p>The key mental model: Widget is a class. @Composable is a function.</p><h3>The Full Translation</h3><p>Flutter Android pubspec.yaml build.gradle.kts assets/ res/ main() MainActivity runApp() setContent {} Widget @Composable build() Recomposition</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c723abd82ac7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How Android Actually Works — A Flutter Dev’s Notes]]></title>
            <link>https://medium.com/@h.umarahmad107/how-android-actually-works-a-flutter-devs-notes-f4aa76ee468a?source=rss-425a189b8b4f------2</link>
            <guid isPermaLink="false">https://medium.com/p/f4aa76ee468a</guid>
            <category><![CDATA[android-architecture]]></category>
            <category><![CDATA[flutter-vs-andriod]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[android-app-development]]></category>
            <dc:creator><![CDATA[Hafiz Umar Ahmad Siddiqui]]></dc:creator>
            <pubDate>Sun, 19 Jul 2026 13:48:54 GMT</pubDate>
            <atom:updated>2026-07-19T13:50:40.634Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/738/1*oQcXHOLcdb8SakzPXST4PA.png" /><figcaption>Andriod view of a Flutter Engineer</figcaption></figure><p>Coming from Flutter, I kept mapping everything I saw in Android back to what I already knew. Some of it translated. A lot of it didn’t.</p><p>This is what I actually learned about how Android works, not from reading docs top to bottom, but from trying to build something and stopping every time something didn’t make sense.</p><h3>The OS Owns Everything</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/385/1*OWgpz1-Oc2PM8XTd_oLt4Q.png" /></figure><p>This is the first mental model shift, and it changes how you read everything else.</p><p>In Flutter, you write main(), call runApp(), and from that point you&#39;re in control. You manage the widget tree, you decide what renders, you call setState() when something changes.</p><p>Android doesn’t work like that.</p><p>When someone taps your app icon, the OS creates an Activity and then starts calling lifecycle methods on it. You didn’t start the app. Android started it, and then called you. Your job is to respond.</p><p>The architecture reflects this:</p><pre>App → Android Framework → Android Runtime (ART) → HAL(Hardware Abstraction Layer) → Linux Kernel → Hardware</pre><p>Your code sits at the very top. Everything below it — the framework, the runtime, the hardware abstraction layer, the kernel — is managed and owned by the OS. You write behaviour. Android decides when to execute it.</p><p>Flutter apps run differently here. A Flutter app runs on its own Dart VM and uses Android APIs underneath. The Flutter engine sits inside an Android Activity and draws its own UI, largely bypassing the standard Android view system. This is why switching to native Android development feels like a different world — you’re now dealing with the actual Android system directly.</p><h3>The 4 Major Components</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/490/1*v8pd_H15H7ee-sNRPmkimw.png" /></figure><p>In Android, everything is a component. There are four major types:</p><ul><li><strong>Activity</strong> — a window or container where the user interacts with the UI</li><li><strong>Service</strong> — runs operations in the background, no UI</li><li><strong>BroadcastReceiver</strong> — listens to system-wide events (battery low, incoming calls, etc.)</li><li><strong>ContentProvider</strong> — manages and shares data between apps</li></ul><p>An Activity is the one Flutter developers encounter first, and it’s easy to mistake it for a “screen.” It’s not exactly that. It’s a window — a container. And the important part is that the OS manages these windows, not your application.</p><h3>How the OS Manages Your App</h3><p>There is one Application object per app process. Under it, there can be multiple Activities:</p><pre>Application<br>     │<br>     ├── Activity A<br>     ├── Activity B<br>     └── Activity C</pre><p>But your app doesn’t manage these. The OS does. At any point, Android can:</p><ul><li>Pause one Activity</li><li>Resume another</li><li>Destroy one Activity entirely</li><li>Keep the Application alive in the background</li><li>Recreate an Activity when needed (screen rotation, for example)</li></ul><p>Your code has no say in when this happens. Which leads to the next thing.</p><h3>Lifecycle Methods Are OS Notifications</h3><p>onCreate(), onDestroy(), onPause(), onResume() → these are not methods you call. They&#39;re notifications from the OS telling you what just happened or what&#39;s about to happen.</p><p>Android calls them. You respond to them.</p><p>This is the Inversion of Control pattern at work. In Flutter, you call things. In Android, the framework calls you. Once that clicks, the entire lifecycle model starts making sense.</p><h3>What an Intent Is</h3><p>An <strong>Intent</strong> is a request sent to Android asking it to perform an action.</p><p>Want to open the camera? You don’t open it directly. You send an Intent to Android, and Android handles it. Want to navigate to another screen in your own app? Also an Intent. Want to share content? Intent.</p><p>This is consistent with the OS-ownership model. You don’t reach out and grab things. You make requests, and the OS decides what to do with them.</p><h3>Back Doesn’t Kill Your App</h3><p>One thing that caught me off guard: pressing Back finishes the current Activity — it doesn’t necessarily kill the entire app process.</p><p>The Application object stays alive. Only the Activity on screen gets finished. This matters because any state living in the Application, or in a background Service, can outlive what’s visible on screen. The app process and the visible UI are separate concerns.</p><h3>The Takeaway</h3><p>The single most important thing to understand about Android is this: the OS is in charge, not you.</p><p>Everything from creating windows, managing their lifecycle, handling inter-process communication, even deciding when your app gets destroyed, ultimately is the OS’s decision. Your code is a guest. The lifecycle methods, the component model, the Intent system, all of it exists because Android needs a structured way to let your code participate in a system it doesn’t control.</p><p>Once that mental model is in place, the rest of Android starts to make sense.</p><p>Next up: the project structure, the Manifest, and getting into Jetpack Compose.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f4aa76ee468a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Flutter Riverpod — Everything you should Know]]></title>
            <link>https://medium.com/@h.umarahmad107/flutter-riverpod-everything-you-should-know-5be92c609370?source=rss-425a189b8b4f------2</link>
            <guid isPermaLink="false">https://medium.com/p/5be92c609370</guid>
            <category><![CDATA[flutter-state-management]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[flutter-riverpod]]></category>
            <category><![CDATA[riverpod]]></category>
            <category><![CDATA[flutter-app-development]]></category>
            <dc:creator><![CDATA[Hafiz Umar Ahmad Siddiqui]]></dc:creator>
            <pubDate>Fri, 03 Jul 2026 06:46:13 GMT</pubDate>
            <atom:updated>2026-07-05T09:14:28.696Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/596/1*r2e5_CKbTAzuNUwZiaOkQw.jpeg" /></figure><p>Riverpod is a popular tool for state management used extensively by the developers to make the flutter mobile app more scalable, more error resistant, more future proof for modifications and more robust.</p><p>Riverpod is an upgrade on the <em>Provider </em>package and deal with the shortcomings and problems with it. You can say Super-Charged and more secure Provider :)</p><blockquote>Riverpod is a state management library for Flutter that solves the limitations of (provider package) by being compile-safe, testable outside widgets, and not dependent on Provider (the BuildContext).</blockquote><p>Below we discussed the elements (types of providers) of the riverpod package and Where to use them and how to use them as well in the later part:</p><h3>Types of Providers in the Riverpod Package:</h3><p>Below discussed providers are all of category immutable, meaning the value can’t be changed once created (They have to be completely replaced by new instance) making it secure, and more efficient.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/969/1*SulTwouh8099DGLYyoY1xA.png" /></figure><h3>Simple Providers</h3><h4>1. Provider — For Non changeable values</h4><p>Holds a value that doesn’t change after creation. Good for services, repositories, constants, or any derived/computed value.</p><pre>final greetingProvider = Provider&lt;String&gt;((ref) {<br>return &quot;Hello, Riverpod!&quot;;<br>});<br>final apiServiceProvider = Provider&lt;ApiService&gt;((ref) {<br>return ApiService();<br>})</pre><p>Every provider’s builder function gets a ref parameter — this is how a provider talks to other providers (read them, watch them, listen to them)</p><h4>2. StateProvider — Value can be changed</h4><p>Used for simple pieces of state that change over time: a counter, a toggle, a selected filter, etc. Not meant for complex objects</p><pre>final counterProvider = StateProvider&lt;int&gt;((ref) =&gt; 0)</pre><p>to change the value of provided state</p><pre>ref.read(counterProvider.notifier).state = ref.read(counterProvider) + 1;<br>// or, using update:<br>ref.read(counterProvider.notifier).update((state) =&gt; state + 1)</pre><p><em>.notifier </em>gives access to the underlying <em>StateController </em>, which exposes <em>.state </em>and be directly manipulated or the <em>.update()</em> method to derive a new value from the old one.</p><h3>Complex Provider (For Complex task / State)</h3><p>When state is more than a single primitive value — a custom object, a list, multiple related fields — <em>StateProvider</em> isn’t enough. This is where <em>StateNotifier</em> comes in.</p><h4>1. StateNotifier and StateNotifierProvider</h4><p><em>StateNotifier</em> is a class that wraps a piece of <em>state ( T )</em> and exposes methods to mutate it. Riverpod listens to it and rebuilds widgets whenever the state changes.</p><pre>// 1. The state class<br>class CartState {<br>  final List&lt;String&gt; items;<br>  CartState(this.items);<br>}<br>// 2. The notifier — holds and mutates the state<br>class CartNotifier extends StateNotifier&lt;CartState&gt; {<br>  CartNotifier() : super(CartState([]));<br>  void addItem(String item) {<br>    state = CartState([...state.items, item]);<br>  }<br>}<br>// 3. The provider — exposes the notifier to the widget tree<br>final cartProvider = StateNotifierProvider&lt;CartNotifier, CartState&gt;((ref) {<br>  return CartNotifier();<br>});</pre><p>Note that state is always replaced, never mutated in place (<em> state = CartState([…]) ,not state.items.add(…)</em> ). This immutability is what allows Riverpod to detect changes and rebuild correctly</p><h4>2. FutureProvider — For Async Functions</h4><p><em>FutureProvider</em> wraps a <em>Future </em>and gives back an over the <em>AsyncValue</em> , which is an upgrade over<em>snapshot </em>you’d normally handle manually with <em>FutureBuilder </em>. The <em>.when()</em> method built into <em>AsyncValue </em>handles <em>data</em>, <em>loading</em>, and <em>error </em>states for you — no boilerplate</p><pre>if (snapshot.hasError){}else if (snapshot.connectionState…)</pre><p>making it simple</p><pre>final userProvider = FutureProvider&lt;User&gt;((ref) async {<br>  final repository = ref.read(userRepositoryProvider);<br>  return repository.fetchUser();<br>})</pre><p>using it in this way:</p><pre>final userAsync = ref.watch(userProvider);<br>userAsync.when(<br>    data: (user) =&gt; Text(user.name),<br>    loading: () =&gt; const CircularProgressIndicator(),<br>    error: (err, stack) =&gt; Text(&#39;Error: $err&#39;),<br>)</pre><p>Passing a parameter into a <em>FutureProvider</em>: a plain <em>FutureProvider</em> only takes <em>ref </em>as paramter, if you need to pass an argument (e.g. a user ID), use <em>.family()</em></p><pre>final userByIdProvider = FutureProvider.family&lt;User, String&gt;((ref, userId) as<br>final repository = ref.read(userRepositoryProvider);<br>return repository.fetchUserById(userId);<br>});<br><br>// usage:<br>ref.watch(userByIdProvider(&#39;user_123&#39;);</pre><p><em>.family</em> only accepts one parameter. If multiple values need to be passed in, the two common solutions :</p><ol><li>Using the tuple package, e.g. <em>FutureProvider.family&lt;User, Tuple2&lt;String, int&gt;&gt; </em>.</li><li>Creating a small <em>@immutable</em> class to bundle the parameters together:</li></ol><pre>@immutable<br>class UserQuery {<br>  final String userId;<br>  final bool includeDetails;<br>  const UserQuery(this.userId, this.includeDetails);<br>}<br><br>final userByQueryProvider = FutureProvider.family&lt;User, UserQuery&gt;((ref, query<br>// use query.userId, query.includeDetails<br>});</pre><h4>3. Stream Provider — for Stream Values</h4><p>Same idea as <em>FutureProvider </em>, but for a Stream. Useful for things like Firestore real-time listeners or WebSocket data. It also exposes an <em>AsyncValue </em>, so .<em>when()</em> works the same way previously discussed.</p><pre>final messagesProvider = StreamProvider&lt;List&lt;Message&gt;&gt;((ref) {<br>  final repository = ref.read(chatRepositoryProvider);<br>  return repository.messageStream();<br>})</pre><h4>4. Notifier class and NotifierProvider — Riverpod 3.0</h4><p><strong>NotifierProvider</strong> (and its asynchronous equivalent, <strong>AsyncNotifierProvider</strong>) is the recommended, modern way in Flutter Riverpod to manage state along with its business logic in a single class.</p><pre>import &#39;package:flutter/material.dart&#39;;<br>import &#39;package:flutter_riverpod/flutter_riverpod.dart&#39;;<br><br>// ─── State model ───────────────────────────────────────────────────────────────<br><br>class CartItem {<br>  final String id;<br>  final String name;<br>  final double price;<br><br>  const CartItem({required this.id, required this.name, required this.price});<br>}<br><br>// ─── Notifier ──────────────────────────────────────────────────────────────────<br><br>class CartNotifier extends Notifier&lt;List&lt;CartItem&gt;&gt; {<br>  @override<br>  List&lt;CartItem&gt; build() {<br>    // initial state — empty cart<br>    return [];<br>  }<br><br>  void addItem(CartItem item) {<br>    state = [...state, item];<br>  }<br><br>  void removeItem(String id) {<br>    state = state.where((item) =&gt; item.id != id).toList();<br>  }<br><br>  void clear() {<br>    state = [];<br>  }<br><br>  double get total =&gt;<br>      state.fold(0.0, (sum, item) =&gt; sum + item.price);<br>}<br><br>// ─── Provider ──────────────────────────────────────────────────────────────────<br><br>final cartProvider = NotifierProvider&lt;CartNotifier, List&lt;CartItem&gt;&gt;(() {<br>  return CartNotifier();<br>});<br></pre><h3>Methods to Read Providers Value</h3><p>By following methods you can use the provider states in your app:</p><h4>1. ConsumerWidget()</h4><p>A <em>StatelessWidget </em>replacement that gives you a <em>WidgetRef </em>in the <em>build </em>method.</p><pre>class CounterText extends ConsumerWidget {<br>  const CounterText({super.key});<br>  <br>  @override<br>  Widget build(BuildContext context, WidgetRef ref) {<br>    final count = ref.watch(counterProvider);<br>    return Text(&#39;Count: $count&#39;);<br>  }<br>}</pre><h4>2. Consumer</h4><p>Used to scope a <em>ref </em>to a small part of the widget tree, without converting the whole widget into a <em>ConsumerWidget </em>. Handy when only one small section of a larger widget needs to rebuild</p><pre>Consumer(<br>  builder: (context, ref, child) {<br>  final count = ref.watch(counterProvider);<br>  return Text(&#39;Count: $count&#39;);<br>  },<br>)</pre><h4>3. ConsumerStatefulWidget</h4><p>The <em>StatefulWidget </em>equivalent — used when you need both local widget state (via <em>initState </em>, <em>controllers</em>, etc.) and access to providers as well. The corresponding state class is <em>ConsumerState </em>, and <em>ref </em>is available inside it (including in <em>build</em>)</p><pre>class CounterPage extends ConsumerStatefulWidget {<br>  const CounterPage({super.key});<br>  @override<br>  ConsumerState&lt;CounterPage&gt; createState() =&gt; _CounterPageState();<br>}<br><br>class _CounterPageState extends ConsumerState&lt;CounterPage&gt; {<br>  @override<br>  Widget build(BuildContext context) {<br>    final count = ref.watch(counterProvider);<br>    return Text(&#39;Count: $count&#39;);<br>  }<br>}</pre><p><strong>ref can be further used in three ways :</strong><br>1. <em>ref.watch(providerName) </em>— continuous reading. Use this inside <em>build()</em> ; the widget rebuilds automatically whenever the provider’s value changes.</p><pre>final count = ref.watch(counterProvider);</pre><p>2. <em>ref.read(providerName) </em>for a one-time read use. Use this outside of b<em>uild() Method</em> (for example inside a button’s <em>onPressed </em>), since reading change.</p><pre>onPressed: () =&gt; ref.read(counterProvider.notifier).state++,</pre><p>3. <em>ref.watch(providerName.select((value) =&gt; value.someProperty)) </em>fir listening to only one property of a provider’s value, instead of the whole object. This avoids unnecessary rebuilds when unrelated fields on that object change</p><pre>final itemCount = ref.watch(cartProvider.select((cart) =&gt; cart.items.length));</pre><p>That’s all about it, we have covered all the stuff related to riverpod needed to start your state management journey, Thanks!</p><p>Edit: in flutter riverpod 3.0 <em>StateProvider, StateNotifierProvider </em>is being depreciated and move to <em>flutter_riverpod/legacy.dart </em>file, no longer available to main api, this is to This is to discourage their use in favor of the new Notifier API.</p><p>If you want to learn about BLoC state management in the detail, you can read it <a href="https://medium.com/@h.umarahmad107/flutter-bloc-state-management-masterclass-i-1ff85a6eecb2"><em>here</em></a><em>.<br>Happy learning !</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5be92c609370" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Flutter BLoC— State Management Masterclass-II]]></title>
            <link>https://medium.com/@h.umarahmad107/flutter-bloc-state-management-masterclass-ii-84f70495d177?source=rss-425a189b8b4f------2</link>
            <guid isPermaLink="false">https://medium.com/p/84f70495d177</guid>
            <category><![CDATA[bloc]]></category>
            <category><![CDATA[dart]]></category>
            <category><![CDATA[scalable-code]]></category>
            <category><![CDATA[flutter-state-management]]></category>
            <category><![CDATA[flutter-app-development]]></category>
            <dc:creator><![CDATA[Hafiz Umar Ahmad Siddiqui]]></dc:creator>
            <pubDate>Wed, 01 Jul 2026 06:16:31 GMT</pubDate>
            <atom:updated>2026-07-01T06:17:02.825Z</atom:updated>
            <content:encoded><![CDATA[<h4>A guide to Flutter Bloc — Getting started with an example</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5B9cpS_GFWiht5IMW7_yOg.jpeg" /></figure><p>This is second part of the masterclass, you can read the first article from <a href="https://medium.com/@h.umarahmad107/flutter-bloc-state-management-masterclass-i-1ff85a6eecb2">here</a>, in which introduction and benefits are given.</p><p>In this flutter project we will be using a Firebase authentication example and try to understand about the bloc.</p><p>first of all,Run this command in your app directory :</p><pre> flutter pub add flutter_bloc</pre><h4>1. BlocEvents — AuthEvents</h4><p>Now our AuthEvents are the Events or Conditions occured during our authentication.<br>We will have 4 AuthEvents:</p><pre>part of &#39;auth_bloc.dart&#39;;<br><br>@immutable<br>sealed class AuthEvent {}<br><br>final class AuthStarted extends AuthEvent {}<br><br>final class AuthEmailSignUpRequested extends AuthEvent {<br>  final String email;<br>  final String password;<br>  final String name;<br><br>  AuthEmailSignUpRequested({<br>    required this.name,<br>    required this.email,<br>    required this.password,<br>  });<br>}<br><br>final class AuthSignInRequested extends AuthEvent {<br>  final String email;<br>  final String password;<br><br>  AuthSignInRequested({required this.email, required this.password});<br>}<br><br>final class AuthSignOutRequested extends AuthEvent {}</pre><p><strong>AuthEvent</strong> is the parent class and every other class will be extending it <br>Let we see everyone class one by one:</p><p><strong>AuthEmailSignUpRequested </strong>is the event occured when the user wants to signUp via email, this event is hold the email, password and name.</p><p><strong>AuthSignInRequested </strong>is the event occured when there is a request of signin from the user, this event cannot occured without email and password so the events holds and demands for both in the constructor</p><p><strong>AuthSignOutRequested </strong>is for sign in out, it doesnt require anything as there is no need of anything for firebase signout function</p><h4>2. BlocStates — AuthStates</h4><p>AuthStates are state of the Auth which is effected by the events occured during the lifetime of the app. For this we have 4 State classes</p><pre>part of &#39;auth_bloc.dart&#39;;<br><br>@immutable<br>sealed class AuthState {}<br><br>final class AuthInitial extends AuthState {}<br><br>final class AuthSuccess extends AuthState {<br>  final User user;<br><br>  AuthSuccess({required this.user});<br>}<br><br>final class AuthFailure extends AuthState {<br>  final String errorMessage;<br><br>  AuthFailure({required this.errorMessage});<br>}<br><br>final class AuthLoading extends AuthState {}</pre><p><strong>AuthState</strong> is again the parent class of all other state classes</p><p>And <strong>AuthSuccess, AuthFaliure, AuthInitial &amp; AuthLoading </strong>is the state classes or simply the states being observed in the Authentication process, Each having particular attributes respective to the state being observed.</p><h4>3. Bloc— AuthBloc (The main logic handler)</h4><pre>class AuthBloc extends Bloc&lt;AuthEvent, AuthState&gt; {<br>  final AuthRepository _authRepository;<br><br>  AuthBloc(this._authRepository) : super(AuthInitial()) {<br>    on&lt;AuthStarted&gt;(_onAuthStarted);<br>    on&lt;AuthEmailSignUpRequested&gt;(_onAuthEmailSignUpRequested);<br>    on&lt;AuthGoogleSignUpRequested&gt;(_onAuthGoogleSignUpRequested);<br>    on&lt;AuthSignInRequested&gt;(_onAuthSignInRequested);<br>    on&lt;AuthSignOutRequested&gt;(_onAuthSignOutRequested);<br>  }<br>  void _onAuthStarted(AuthStarted event, Emitter&lt;AuthState&gt; emit) async {<br>    emit(AuthLoading());<br>    try {<br>      final firebaseuser = await _authRepository.getUser();<br>      if (firebaseuser != null) {<br>        final userData = await _authRepository.getUserData(firebaseuser.uid);<br>        if (userData != null) {<br>          emit(AuthSuccess(user: userData));<br>          return;<br>        }<br>      }<br>    } on Exception catch (e) {<br>      debugPrint(e.toString());<br>    }<br>    return emit(AuthInitial());<br>  }<br><br>  void _onAuthSignInRequested(<br>    AuthSignInRequested event,<br>    Emitter&lt;AuthState&gt; emit,<br>  ) async {<br>    emit(AuthLoading());<br>    final String email = event.email;<br>    final String password = event.password;<br>    if (password.length &lt; 6) {<br>      return emit(<br>        AuthFailure(<br>          errorMessage: &#39;Password cannot be smaller than 6 characters&#39;,<br>        ),<br>      );<br>    }<br>    if (!(email.contains(&#39;@&#39;))) {<br>      return emit(AuthFailure(errorMessage: &#39;Invalid Email&#39;));<br>    }<br>    try {<br>      final Result result = await _authRepository.signInWithEmail(<br>        email,<br>        password,<br>      );<br>      if (result.isSuccess) {<br>        return emit(AuthSuccess(user: result.data!));<br>      }<br>    } catch (e) {<br>      return emit(AuthFailure(errorMessage: e.toString()));<br>    }<br>    return emit(AuthFailure(errorMessage: &#39;Email sign-in Failed&#39;));<br>  }<br>}</pre><p>Now that’s the main logic handler, AuthBloc class.</p><p>Their is a Authrepository holding down the data handling, as a class attribute and initial state being set via <strong>super(AuthInitial()) </strong>keyword .</p><p>We have use on&lt;event e&gt;(future function()) to tell the bloc classes to run these functions on these events and the logic is being cater in the respective functions, I have used 5 of these and have shown the implementation of two to make it simple and understandable.</p><p>So whenever an event is being pushed in the main app the respective function runs and the logic flows.</p><h4>4. Using</h4><p>using is a bit straight forward in this case, either you can use it with context.select, like <strong><em>.select&lt;Auth, any data type being return&gt;((bloc) {} )</em></strong></p><pre>final user = context.select&lt;AuthBloc, model.User?&gt;((bloc) {<br>      final state = bloc.state;<br>      return (state is AuthSuccess) ? state.user : null;<br>    });</pre><p>or you can use it with Bloc Builder like this:</p><pre>return BlocBuilder&lt;AuthBloc, AuthState&gt;(<br>      builder: (context, state) {<br>        if (state is AuthLoading) {<br>          return const Scaffold(<br>            body: Center(child: CircularProgressIndicator()),<br>          );<br>        } else if (state is AuthSuccess) {<br>          final user = context.select&lt;AuthBloc, model.User?&gt;((bloc) {<br>            final state = bloc.state;<br>            return (state is AuthSuccess) ? state.user : null;<br>          });<br>          if (user != null) {<br>            context.read&lt;TopicBloc&gt;().add(<br>              TopicsByUidRequested(uid: user.uid),<br>            ); //it will just scheduled the notifications<br>          }<br>          return const Home();<br>        } else {<br>          return const Signup();<br>        }<br>      },<br>    );</pre><p>Their is more ways to use this, but these are sufficient in most of the cases.</p><p>THAT’s IT. You have successfully used Bloc managament in your app and it works wonder, making your app scalable, less error prone and future proof for furture modification, you can read detail benefits about bloc from <a href="https://medium.com/@h.umarahmad107/flutter-bloc-state-management-masterclass-i-1ff85a6eecb2?sharedUserId=h.umarahmad107">here</a></p><p>If you have any ambguities about it or have some suggestions don’t hesitate to ask via comment or contact me, i’ll be more than happy to share.</p><p>Thanks, and happy learning.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=84f70495d177" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Flutter BLoC — State Management Masterclass-I]]></title>
            <link>https://medium.com/@h.umarahmad107/flutter-bloc-state-management-masterclass-i-1ff85a6eecb2?source=rss-425a189b8b4f------2</link>
            <guid isPermaLink="false">https://medium.com/p/1ff85a6eecb2</guid>
            <category><![CDATA[flutter-bloc]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[bloc]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Hafiz Umar Ahmad Siddiqui]]></dc:creator>
            <pubDate>Fri, 25 Jul 2025 14:24:48 GMT</pubDate>
            <atom:updated>2026-07-01T06:18:25.863Z</atom:updated>
            <content:encoded><![CDATA[<h3>Flutter BLoC — State Management Masterclass-I</h3><h4>A guide to Flutter Bloc — Introduction and Benefits</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5B9cpS_GFWiht5IMW7_yOg.jpeg" /></figure><p>In this article we will :</p><ol><li>Understand the flutter bloc</li><li>Benefits of flutter bloc</li><li>Example code- Auth Management</li></ol><h3>BLoC State Management — Overview</h3><p>Flutter bloc state management is a flutter package which helps us to manage state. Bloc provide clear seperation between the <strong><em>Buiness</em></strong>, <strong><em>Logic </em></strong>and <strong><em>UI. </em></strong>It uses the states and events to ensure seem less state management.</p><blockquote>Event → Bloc → New State → UI</blockquote><p>When Event occurs it is catched by the bloc and acting upon it some State change is being made and that change is shown in the UI</p><p>It provides many useful features along with some features of <strong><em>Provider</em></strong> as it extends from it. Some of the most important features provided by the flutter bloc includes:</p><ol><li>BlocProvider (feature from provider)</li><li>MultiBlocProvider (feature from provider)</li><li>BlocListener (Listen to state changes and perform side-effects (e.g., navigation, snackbar))</li><li>MultiBlocListner</li><li>BlocBuilder (Provide UI rebuilds of some selected widgets, upon some state changes)</li><li>BlocConsumer ( BlocBuilder + BlocListener)</li></ol><h3>BLoC State Management — Benefits</h3><h4>1. Separation of Concerns</h4><p>Bloc enforces strict seperation between buisness logic and UI, making it modular, cleaner and scalable.</p><h4>2. Predictable State Flow</h4><p>Bloc uses a unidirectional data flow making the state transitions predictable and traceable, reducing debugging complexity.</p><p>Event → Bloc → New State → UI</p><h4>3. Easy Testing &amp; Debugging</h4><p>Bloc have built-in tool for debugging and tesing like BlocObserver() which tracks the state changes globally and bloc_test() for unit testing</p><h4>4. Better Fit for Complex Apps</h4><p>Bloc provide more structured way of state management which makes the app cleaner, and more modular, which helps in scalability and testing, It is best fit for:</p><ol><li>Multiple user roles</li><li>Authentication</li><li>Multi-step forms</li><li>Complex interactions</li></ol><h4>5. More Suitable for Big Teams:</h4><p>Modularity provided by the bloc is exactly needed for big teams, the diffrent teams can work on diffrent modules without the worry for the logic and state management, just build with events and states</p><p>You can read about how to get started with bloc in this <a href="https://medium.com/@h.umarahmad107/flutter-bloc-state-management-masterclass-ii-84f70495d177?postPublishedType=repub">article</a>, i have given a practical guide with an example.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1ff85a6eecb2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Circle Theory — My Approach to Avoiding and Staying Unaffected by Toxic People]]></title>
            <link>https://medium.com/@h.umarahmad107/circle-theory-my-approach-to-avoiding-and-staying-unaffected-by-toxic-people-0ff1eedb7e39?source=rss-425a189b8b4f------2</link>
            <guid isPermaLink="false">https://medium.com/p/0ff1eedb7e39</guid>
            <dc:creator><![CDATA[Hafiz Umar Ahmad Siddiqui]]></dc:creator>
            <pubDate>Sat, 02 Nov 2024 15:16:34 GMT</pubDate>
            <atom:updated>2024-11-02T15:16:34.572Z</atom:updated>
            <content:encoded><![CDATA[<h3>Circle Theory — My Approach to Avoiding and Staying Unaffected by Toxic People</h3><p>A lot of the time in your life, you deal with lots of toxicity and bad behavior from different people. That is the basic nature of people, they often hurt you mentally and physically. We often get sad by the actions of these people. If you ever felt this, I am giving you a cheat code to overcome this problem. Let’s start:</p><h3>Drawing the Circle:</h3><ol><li>The first step to overcome this situation is to mentally draw a circle of relations.</li><li>After this, you should try to identify the most trusted, favorite and closest personals to you</li><li>Put them in the inner circle.</li></ol><p>It should consist of some 5 to 15 people. These relations can be anyone (must be closest), mother, brother, some friends, your wife or girlfriend. Everyone after these goes to the outer circle.</p><h3>Dealing with People of Inner Circle:</h3><p>These are the people you count. These are the people you care about. Their opinions matter about your personal and social life, and you listen to their advice and criticism. You always care for them and they always care for you. In this fleeting world, there are a few real people who truly make a difference.</p><p>It is almost certain that there will be some issues, there will be some problems. There will be some actions of them which will hurt you and some of yours which will hurt them. It is completely normal, but <em>you don&#39;t let them go</em>. You will fight with them, only because they are worth fighting with. They are truly a personals which you can&#39;t afford to lose. You should fight, laugh, play, and care about them because they are the <strong>Inner People.</strong></p><h3>Dealing with People of Outer Circle:</h3><p>These are the people you should always follow the rule:</p><blockquote><em>“No matter what, I will be good with you, but in return, </em><strong><em>I will not expect good from you</em></strong><em>.”</em></blockquote><p>This is an evil world we live in, that’s true, and everyone should accept it. Being human we should always help and teach others the things which you have learned, but by simply not accepting the same treatment from others makes it easy to digest the bitterness of the world. You should not count them as important in your life, you should not give them importance as they have and will be harming you in every way possible. Therefore,</p><blockquote>“Always try to ease the life of others but don’t ever expect them others to make your life easy<em>”</em></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0ff1eedb7e39" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>